从目标C中的图像中读取非标准属性

sha*_*rgy 6 jpeg properties image-processing objective-c

我正在使用此代码(将图像元数据(EXIF/TIFF/IPTC)写入OS X中的图像文件)从图像文件中读取EXIF/TIFF/IPTC数据.它工作得很好,但我还需要复制剪切路径.它被保存到一个名为"Photoshop"的非标准索引(就像其他人称为Iptc和类似的一样).

我无法弄清楚如何访问此信息以将其复制到新创建的NSImage.链接中的方法似乎不访问任何非标准信息.任何帮助赞赏.谢谢

编辑----

这是一个示例图像:http://www.mad-sharky.com/clipping_path.jpg

这个包含一个剪切路径,可以通过这个工具验证:http://regex.info/exif.cgi 你可以看到"Photoshop"部分.该部分包含我正在使用的代码中缺少的所有数据.(代码与上面的链接相同)

mar*_*nte 2

我只有一个旧的 .psd 文件,没有剪切路径。但确实有层次。

这段简短的示例代码使用了 Photoshop 图像属性。 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);
Run Code Online (Sandbox Code Playgroud)

在我的图像中,我有一些图像层:

在此输入图像描述

上面代码中的 NSLog 返回

imageRead[11220:452087] bim { LayerNames = ("第 0 层", "第 5 层", "第 6 层", "第 4 层", "第 3 层", "第 2 层", "第 1 层"); 版本=1;}

如果我想知道我可以使用的所有键:

id allKeys = [bim allKeys];
     NSLog(@"allKeys %@",allKeys);
Run Code Online (Sandbox Code Playgroud)

并得到:

imageRead[11531:463848] allKeys (版本, LayerNames)

然后我可以使用:

id LayerNames = [bim objectForKey:@"LayerNames"];
 NSLog(@"LayerNames %@",LayerNames);
Run Code Online (Sandbox Code Playgroud)

要得到 :

imageRead[11563:465657] LayerNames (“第 0 层”、“第 5 层”、“第 6 层”、“第 4 层”、“第 3 层”、“第 2 层”、“第 1 层”)

或者

valueForKey: , allValues

不幸的是,我无法测试剪切路径是否会回来