• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Writing EXIF UserComment using Cocoa/CF
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Writing EXIF UserComment using Cocoa/CF


  • Subject: Writing EXIF UserComment using Cocoa/CF
  • From: "Klaus L. Greulich" <email@hidden>
  • Date: Tue, 28 Feb 2006 20:16:13 +0100

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:
This email sent to email@hidden


  • Prev by Date: NSTableView - "restoring previous value" when committing editing with empty string?
  • Next by Date: Trouble with passing variables
  • Previous by thread: NSTableView - "restoring previous value" when committing editing with empty string?
  • Next by thread: Trouble with passing variables
  • Index(es):
    • Date
    • Thread