Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Writing EXIF UserComment using Cocoa/CF



Hi!

My Problem is that I need to write some information in a jpeg file, using the EXIF "UserComment" tag.

Reading Exif information is not the problem, it is simply done by:

mMetadata = (CFMutableDictionaryRef)CGImageSourceCopyPropertiesAtIndex (source, 0, (CFDictionaryRef)options);

NSDictionary* exif = [(NSDictionary*)mMetadata objectForKey:@"{Exif}"];

(Thanks for the Sample Code "ImageApp" from Apple)

That gives me (printed via NSLog) the following:

[...]
DateTimeOriginal = "2006:02:26 11:13:17";
[...]
UserComment = "                                    ";
[...]

Writing *some* information also seems not to be a problem, because:

NSMutableDictionary* newExif = [NSMutableDictionary dictionaryWithDictionary:[newMetadata objectForKey:@"{Exif}"]];

[newExif setObject:@"2001:01:01 11:53:07" forKey:@"DateTimeOriginal"];
[newExif setObject:@"This is a test" forKey:@"UserComment"];
[newMetadata setObject:newExif forKey:@"{Exif}"];

CGImageDestinationCreateWithURL((CFURLRef)absURL, (CFStringRef) typeName, 1, nil);
CGImageDestinationAddImage(dest, image, (CFDictionaryRef)newMetadata);


gives me:

[...]
DateTimeOriginal = "2001:01:01 11:53:07"; <-- That works, the entry has been changed!
[...]


But there is no "UserComment" Tag ...

It is not only not changed, it is gone.

"UserComment" is the only tag I care about at the moment, because for my project I need to write some information (Copyright, Information about the image) in the jpeg file. :-(

Is that a known bug or did I something wrong? Changing "DateTimeOriginal" worked without any problems ...

I know there are some third-party tools to write EXIF information, but it would be much easier and elegant using Cocoa (NSBitmapImageReps valueForProperty) or CoreFoundation for this task.

Perhaps someone has a solution ... ;-)

With best regards

Klaus L. Greulich

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.