On Jun 3, 2008, at 3:11 PM, Heinrich Giesen wrote:

I'm about to resort to using a third-part solution

This is a good idea! My favourite program is exiftool by Phil Harvey:
http://www.sno.phy.queensu.ca/~phil/exiftool/

exiftool -Orientation=8 -n a.jpg

will do the job.

Yep, it does, and looks to be the perfect companion to jpegtran. Thanks for the pointer, I hadn't found this one in my searching.

On Jun 3, 2008, at 9:53 PM, Ken Ferry wrote:

Can we see the code you're using to write the CGImage to the CGImageDestination?

I suspect the difficulty may be that you expect the metadata to be carried with the CGImage.

I was thinking the CGImageSourceRef...

It isn't: You can get all the metadata with CGImageSourceCopyPropertiesAtIndex, then you need to turn around

And I was getting them via CGImageSourceCopyProperties(), which, as you correctly state and I eventually found out, is wrong.

Last, I think rotation can be performed losslessly on a JPEG, but not with anything that ships on current versions of Mac OS X. If that's important, you still might want an external library.

Yeah, I'm using jpegtran to do this, and for some reason (they make a lame [IMO] attempt at explaining why) they don't "fix" the orientation tag when it rotates an image. So enter 'exiftool" as Heinrich suggested above.


On a related note, can anyone tell me if creating a CGImageSourceRef from a file, changing (only) its properties, and writing it back out-- does that cause another (lossy) JPEG compression? As in:

cgImage = CGImageSourceCreateWithURL((CFURLRef)url, NULL);
imageRef = CGImageSourceCreateImageAtIndex(cgImage, 0, NULL);
tmpProps = (NSDictionary *)CGImageSourceCopyPropertiesAtIndex(cgImage, 0, NULL);
props = [[tmpProps mutableCopy] autorelease];
[props setValue:[NSNumber numberWithInt:1] forKey:@"Orientation"];
fileURL = [NSURL fileURLWithPath:filePath];
imageDest = CGImageDestinationCreateWithURL((CFURLRef)fileURL, kUTTypeJPEG, 1, NULL);
CGImageDestinationAddImage(imageDest, imageRef, (CFDictionaryRef)props);
CGImageDestinationFinalize(imageDest);

Does this further degrade my image?
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to