Read custom image properties in object C

I use this code ( Writing image metadata (EXIF / TIFF / IPTC) to an image file in OS X ) to read EXIF ​​/ TIFF / IPTC data from image files. It works fine, but I will also need to copy the clipping path. It was saved in a non-standard index called "Photoshop" (just like others are called Iptc and the like).

I cannot figure out how to access this information in order to copy it to the newly created NSImage. The method in the link does not seem to have access to any non-standard information. Any help appreciated. Thanks

EDIT ----

Here is an example image: http://www.mad-sharky.com/clipping_path.jpg

This one contains a clipping path, it can be checked using this tool: http://regex.info/exif.cgi you can see the "Photoshop" section. This part contains all the data that I do not have, with the code that I use. (The code is the same as the link above)

+6
source share
1 answer

I only have an old .psd file that does not have a clipping path. But it has layers.

This quick bit of sample code uses Photoshop image properties. kCGImageProperty8BIMDictionary

NSURL *imageFileURL = [NSURL fileURLWithPath:@"/users/username/foo.psd"]; CGImageSourceRef imageSource = CGImageSourceCreateWithURL((__bridge CFURLRef)imageFileURL, NULL); NSDictionary *properties = (__bridge_transfer NSDictionary *)CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL); NSDictionary *bim = properties[(__bridge id)kCGImageProperty8BIMDictionary]; NSLog(@"bim %@",bim); CFRelease(imageSource); 

In my image, I have several image layers:

enter image description here

NSLog from the above code returns

imageRead [11220: 452087] bim {LayerNames = ("Level 0", "Layer 5", "Layer 6", "Level 4", "Level 3", "Layer 2", "Level 1"); Version = 1; }

If I wanted to know all the keys that I could use:

 id allKeys = [bim allKeys]; NSLog(@"allKeys %@",allKeys); 

And we get:

imageRead [11531: 463848] allKeys (Version, LayerNames)

Then I could use:

 id LayerNames = [bim objectForKey:@"LayerNames"]; NSLog(@"LayerNames %@",LayerNames); 

To obtain:

imageRead [11563: 465657] LayerNames ("Level 0", "Layer 5", "Layer 6", "Level 4", "Level 3", "Layer 2", "Layer 1")

Or

valueForKey:, allValues

I can’t check if the clipping path will return unfortunately

+2
source

All Articles