• 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
Manipulating images with meta-data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Manipulating images with meta-data


  • Subject: Manipulating images with meta-data
  • From: Randall Meadows <email@hidden>
  • Date: Tue, 3 Jun 2008 11:14:06 -0600

[Sorry for the length, but I've tried to include as much detail as necessary in order to get the best answer.)

My program captures images from a digital camera. Said camera is *always* oriented in a portrait fashion, and the image is created by the camera (as a JPEG) with the appropriate EXIF meta-data that reflects this fact (orientation = 8).

My client has some old hardware that doesn't understand (more accurately, doesn't even look at) the meta-data of the image, and chokes on image files that aren't "normalized" (orientation = 1). So my task is to re-orient the images so this hardware doesn't choke, but also fixes the meta-data so that all data remain consistent (so that programs that DO respect the meta-data will still work with the image correctly).

Why, on a platform known for its graphics-handling capabilities, is this so frickin' hard?! :)

A pristine JPEG downloaded from the camera has a wealth of information stored in meta-data; specifically, when viewed in Preview.app, the "More Info" pane has 5 tabs (GPS, General, Canon, Exif, TIFF), with a total of 53 properties, NOT including the GPS info.

In order to rotate the image and fix the orientation meta-data, I've tried several variations and permutations of:

1. Create an NSImage from the file;
2. Create a CGImageSourceRef from the file;
3. Create a CGImageSourceRef from the NSImage's TIFFRepresentation data;
4. Rotate the image;
5. Write out the file with a CGImageDestination thingie

The best I've managed to do in the way of preserving the meta-data was a sequence of 1, 4, 3, 5. When I look at the resulting image in Preview.app, a vast majority of the meta-data is gone, gone, gone: a grand total of 16 properties in categories General, JFIF, Exif, and TIFF. The greatest loss is nearly all the Exif data, which includes such important information as date/time captured, exposure, ISO, shutter speed, gamma, etc. From the original 34 Exif properties, all I'm left with is Pixel X|Y Dimentions! Even looking at the properties of the CGImage after completing step (3), that's all there is. AND, if I omit the rotation step, the resulting CGImage "orientation" property is still set to 1 (which I know to be an outright lie). WTF?!

I'm about to resort to using a third-part solution (jpegtran and jpegexiforient) that I've found, but Shirley, I must be missing something in the Cocoa/Carbon/Foundation/whatever frameworks that would make my life a lot simpler. Am I right? Or is image manipulation on the Mac really this difficult for programmers?

(Note: NO PART of this particular process involves actually *displaying* the image; that comes later, and will involve the already- processed image file.)

Thanks for sticking with me this far, and thanks in advance for any help!
randy
_______________________________________________


Cocoa-dev mailing list (email@hidden)

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


  • Follow-Ups:
    • Re: Manipulating images with meta-data
      • From: "Ken Ferry" <email@hidden>
    • Re: Manipulating images with meta-data
      • From: Ken Thomases <email@hidden>
    • Re: Manipulating images with meta-data
      • From: Randall Meadows <email@hidden>
  • Prev by Date: Re: Main window disappears. Sometimes.
  • Next by Date: Re: The KVO Race
  • Previous by thread: Re: The KVO Race
  • Next by thread: Re: Manipulating images with meta-data
  • Index(es):
    • Date
    • Thread