Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding custom fields to an images metadata dictionary

Is it possible to add custom dictionary fields to an images metadata?

The following statement

writeImageDataToSavedPhotosAlbum:metadata:completionBlock:

Allows images to be added with metadata.

Is this dictionary (the metadata dictionary) treated as a normal dictionary?

I mean, Is it possible to add custom fields to it.

Of course the original metadata dictionary needs to be copied, but once this is done can it be edited and used.

Also when would this be done? If an image is captured with the iphone and I want to add stuff to the metadata, will this be writing an image twice, or is the first captured images metadata available, modified and then the image is saved with the metadata?

like image 722
some_id Avatar asked Feb 22 '11 14:02

some_id


1 Answers

Yes it is possible to add custom distionary fields to image metadata. You can use unused dictionary keys to write your data within the image metadata. Just u have to do is when u capture the image and get it through image picker, just save it at a location and obtain it's metadata by using :

    NSData *imgData = UIImageJPEGRepresentation(imageView.image, 1);
    CGImageSourceRef source = CGImageSourceCreateWithData((CFMutableDataRef)imgData, NULL);
    NSDictionary *metadata = [(NSDictionary *) CGImageSourceCopyPropertiesAtIndex(source,0,NULL)autorelease];

Then edit image metadata and save image by using :

writeImageDataToSavedPhotosAlbum:metadata:completionBlock:

It will save the new image with metadata inside the iPhone photo library then u can delete the old image if u want.

Hope it might help!!!

like image 169
Rajat Avatar answered Nov 13 '22 12:11

Rajat