Add a value to the Photos Caption field

In the iOS Photos app there is a caption field the user can write to. How can you write to this value from Swift when creating a photo?

I see apps that do this, but there doesn't seem to be any official way to do this using the Photo library through PHAssetCreationRequest or PHAssetResourceCreationOptions or setting EXIF values, I tried settings a bunch of values there including IPTC values but nothing appears in the caption field in the iOS photos app.

There must be some way to do it since I see other apps setting that value somehow after capturing a photo.

Answered by Engineer in 897968022

In the latest 27 beta SDK you will find a new API that provides this: PHAssetExtendedMetadata

You can use this API to fetch the caption, keywords, and original filename for a PHAsset. For caption and keywords there are functions on PHAssetChangeRequest which let you modify them.

More information here: https://developer.apple.com/documentation/photos/phassetextendedmetadata

Accepted Answer

It looks like if you set the kCGImagePropertyIPTCCaptionAbstract value in the kCGImagePropertyIPTCDictionary image metadata dictionary the iOS photos app will show that value in the Photos app.

In the latest 27 beta SDK you will find a new API that provides this: PHAssetExtendedMetadata

You can use this API to fetch the caption, keywords, and original filename for a PHAsset. For caption and keywords there are functions on PHAssetChangeRequest which let you modify them.

More information here: https://developer.apple.com/documentation/photos/phassetextendedmetadata

Add a value to the Photos Caption field
 
 
Q