从目标C中的图像中读取非标准属性 [英] Read non-standard properties from an image in objective C

查看:113
本文介绍了从目标C中的图像中读取非标准属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此代码(



上述代码中的NSLog返回



< blockquote>

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


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

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

获取:


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


我可以使用:

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

获得:


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




valueForKey: allValues



我无法测试如果裁剪路径不幸回来


I'm using this code (Writing image metadata (EXIF/TIFF/IPTC) to image file in OS X) to read EXIF/TIFF/IPTC data from image files. It's working great, but I would also need to copy the clipping path over. It's saved to a non standard index called "Photoshop" (just like the Others are called Iptc and similar).

I can't figure out how to access this information to copy it over to a newly created NSImage. The method in the link does not seem to access any non-standard informations. Any help appreciated. Thanks

EDIT ----

Here is a sample image: http://www.mad-sharky.com/clipping_path.jpg

This one contains a clipping path, it can be verified usign this tool: http://regex.info/exif.cgi you can see the "Photoshop" section. That part contains all the data I am missing with the code I am using. (Code is the same as the link above)

解决方案

I only have an old .psd file which does not have a clipping path. But does have layers.

This quick bit of example code uses the 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 some image layers:

The NSLog from the code above returns

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

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

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

And get:

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

I could then use:

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

to get :

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

Or

valueForKey:, allValues

I cannot test if a clipping path would come back unfortunately

这篇关于从目标C中的图像中读取非标准属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆