Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write image metadata to JPG/PNG file in iOS

Is there any way to write a UIImage to a JPG/PNG file and then append metadata to it? I know you can use:

writeImageDataToSavedPhotosAlbum:metadata:completionBlock

to do this in the Saved Photos, but how do you do the same thing directly to a file? I can't seem to find any way to do this. I know that UIImagePNGRepresentation() and UIImageJPGRepresentation() will give you NSData that you can use to write the file, but there's no way to append/replace the metadata in the file.

Any ideas?

like image 339
rekle Avatar asked Mar 16 '11 19:03

rekle


1 Answers

Looks like a duplicate.

To add metadata to a UIImage you can use the ImageIO framework You can create a CGImageDestination object from a UIImage, add metadata to it using CGImageDestinationSetProperties and then get the raw data (which includes the compressed image and the metadata) from it.

like image 67
NSMutableString Avatar answered Dec 12 '22 01:12

NSMutableString