kCGImagePropertyIPTCKeywords problem

Posted by deepa on Stack Overflow See other posts from Stack Overflow or by deepa
Published on 2010-06-09T04:08:58Z Indexed on 2010/06/09 4:12 UTC
Read the original article Hit count: 203

Filed under:
|
|

Hi,

I am developing an iPhone app in which I want to set the keywords for an image using ImageIO.framework.

Following is the code snippet that I use for setting the keywords. But, it does not apply the keywords to image meta data. Could some one help me out in finding the problem here.

NSMutableDictionary *iptcDictionary = [NSDictionary dictionaryWithObject: [NSArray arrayWithObject: @"Test"] forKey:(NSString *)kCGImagePropertyIPTCKeywords];

NSDictionary *newImageProperties = [NSDictionary dictionaryWithObject:iptcDictionary forKey:(NSString *)kCGImagePropertyIPTCDictionary];

CGImageSourceRef imageSource=CGImageSourceCreateWithURL((CFURLRef)imageURL, nil); //imageURL is URL of source image

CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData( (CFMutableDataRef)newImageFileData, CGImageSourceGetType(imageSource), 1,NULL);

CGImageDestinationAddImageFromSource(imageDestination, imageSource, 0, (CFDictionaryRef) newImageProperties);

if (CGImageDestinationFinalize(imageDestination)) [newImageFileData writeToFile:imagePath atomically:YES]; //imagePath is the path of the destination image with new metadata

Thanks and regards, Deepa

© Stack Overflow or respective owner

Related posts about image

Related posts about metadata