相关疑难解决方法(0)

使用CGImageProperties获取EXIF属性

我希望能够在JPEG的元数据中添加文本注释,并能够从iphone应用程序中读取它.

我认为这很简单,因为ios4包含对EXIF信息的支持.所以我使用一个名为used AnalogExif的Windows工具添加元数据,并使用以下方法从我的应用程序中读回:

NSData *jpeg = UIImageJPEGRepresentation(myUIImage,1.0);

CGImageSourceRef  source = CGImageSourceCreateWithData((CFDataRef)jpeg, NULL);
NSDictionary *metadata = (NSDictionary *) CGImageSourceCopyPropertiesAtIndex(source,0,NULL);

NSMutableDictionary *metadataAsMutable = [[metadata mutableCopy]autorelease];
[metadata release];

NSMutableDictionary *EXIFDictionary = [[[metadataAsMutable objectForKey:(NSString *)kCGImagePropertyExifDictionary]
Run Code Online (Sandbox Code Playgroud)

这有用......到了一点:)

我在元数据字典中得到的是:

(gdb) po metadata
{
   ColorModel = RGB;
   Depth = 8;
   Orientation = 1;
   PixelHeight = 390;
   PixelWidth = 380;
   "{Exif}" =     {
      ColorSpace = 1;
      PixelXDimension = 380;
      PixelYDimension = 390;
   };
   "{JFIF}" =     {
      DensityUnit = 0;
      JFIFVersion = (
        1,
        1
      );
      XDensity = 1; …
Run Code Online (Sandbox Code Playgroud)

xcode iptc exif uiimage cgimagesource

5
推荐指数
1
解决办法
3586
查看次数

标签 统计

cgimagesource ×1

exif ×1

iptc ×1

uiimage ×1

xcode ×1