views:

55

answers:

1

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

A: 

Having the same issue here. I can edit GPSDictionary for sure, I think I can edit the Exif dictionary, but I cannot edit the IPTCDictionary. I see all the keys of the IPTCDictionary in my final Mutable Dictionary, and I basically rewrite the file the same way as you. But the key for IPTCDictionary doesn't seem to be written.

Maybe it is time for a rdar? I'll make some further tests and file mine.

Cyril Godefroy
Actually I tried to edit the iptc of a file where I had put some keywords. The keywords were deleted. Filed a rdar.
Cyril Godefroy