如何在ios中读取图像的完整exif和tiff信息
我正在尝试从图像中提取exif信息如何在ios中读取图像的完整exif和tiff信息,ios,cocoa-touch,image-processing,ios7,exif,Ios,Cocoa Touch,Image Processing,Ios7,Exif,我正在尝试从图像中提取exif信息 UIImage *pImage = [UIImage imageNamed:@"IMG_0011.JPG"]; NSData* pngData = UIImageJPEGRepresentation(pImage, 1.0); CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)pngData, NULL); NSDictionary *metadata = (
UIImage *pImage = [UIImage imageNamed:@"IMG_0011.JPG"];
NSData* pngData = UIImageJPEGRepresentation(pImage, 1.0);
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)pngData, NULL);
NSDictionary *metadata = (__bridge NSDictionary *) CGImageSourceCopyPropertiesAtIndex(source, 0, NULL);
NSLog(@"exif %@" , metadata);
我得到了以下元数据信息
exif {
ColorModel = RGB; <br>
Depth = 8; <br>
Orientation = 1; <br>
PixelHeight = 1936;<br>
PixelWidth = 2592;<br>
"{Exif}" = {
ColorSpace = 1;<br>
PixelXDimension = 2592;<br>
PixelYDimension = 1936;<br>
};
"{JFIF}" = {<br>
DensityUnit = 0;<br>
JFIFVersion = (<br>
1,<br>
1<br>
);
XDensity = 1;<br>
YDensity = 1;<br>
};
"{TIFF}" = {<br>
Orientation = 1;<br>
};
}<br>
exif{
ColorModel=RGB;
深度=8;
方向=1;
像素高度=1936;
像素宽度=2592;
“{Exif}”={
颜色空间=1;
PixelXDimension=2592;
像素尺寸=1936;
};
“{JFIF}”={
密度单位=0;
JFIFVersion=(
1,
1
);
XDensity=1;
密度=1;
};
“{TIFF}”={
方向=1;
};
}
但当我使用exif data viewer或预览应用程序查看图像时,我得到了以下信息
Aperture Value: 2.526<br>
Brightness Value: 1.897<br>
Color Space: sRGB<br>
Components Configuration: 1, 2, 3, 0<br>
Date Time Digitized: 20-Dec-2013 1:33:31 PM<br>
Date Time Original: 20-Dec-2013 1:33:31 PM<br>
Exif Version: 2.2.1<br>
Exposure Mode: Auto exposure<br>
Exposure Program: Normal program<br>
Exposure Time: 1/15<br>
Flash: No flash function<br>
FlashPix Version: 1.0<br>
FNumber: 2.4
Focal Length: 4.28<br>
Focal Length In 35mm Film: 35<br>
ISO Speed Ratings: 125<br>
Metering Mode: Pattern<br>
Pixel X Dimension: 2,592<br>
Pixel Y Dimension: 1,936<br>
Scene Capture Type: Standard<br>
Sensing Method: One-chip color area sensor<br>
Shutter Speed Value: 3.907
Subject Area: 1295, 967, 699, 696
White Balance: Auto white balance<br>
Regions: {
HeightAppliedTo = 1936;<br>
RegionList = (
{
ConfidenceLevel = 326;<br>
FaceID = 3;<br>
Height = "0.172";<br>
Timestamp = 956449648;<br>
Type = Face;<br>
Width = "0.128";
X = "0.542";<br>
Y = "0.426";<br>
}
);
WidthAppliedTo = 2592; <br>
}
光圈值:2.526
亮度值:1.897
颜色空间:sRGB
组件配置:1、2、3、0
数字化日期时间:2013年12月20日下午1:33:31
日期时间原件:2013年12月20日下午1:33:31
Exif版本:2.2.1
曝光模式:自动曝光
曝光程序:正常程序
曝光时间:1/15
闪光:无闪光功能
FlashPix版本:1.0
fn编号:2.4
焦距:4.28
35mm胶片的焦距:35
ISO速度等级:125
计量模式:模式
像素X尺寸:2592
像素Y尺寸:1936
场景捕捉类型:标准
传感方式:单片色域传感器
快门速度值:3.907
主题范围:1295967996
白平衡:自动白平衡
区域:{
高度应用于=1936;
地区列表=(
{
信心水平=326;
FaceID=3;
高度=“0.172”
时间戳=956449648;
类型=面;
宽度=“0.128”;
X=“0.542”
Y=“0.426”
}
);
宽度应用到=2592;
}
有没有关于如何在ios上提取完整exif数据的建议?问题是,您正在通过
UIImage
进行往返,并通过uiimagejpegresentation
转换为NSData
,这将剥夺许多有趣的信息。只需直接加载NSData
:
CGImageSourceRef myImageSource;
myImageSource = CGImageSourceCreateWithURL(url, NULL);
CFDictionaryRef props = CGImageSourceCopyPropertiesAtIndex(myImageSource,0, NULL);
NSDictionary *exif = [(__bridge NSDictionary *)props objectForKey : (NSString *)kCGImagePropertyExifDictionary];
NSString *dateTimeString = [exif objectForKey:(NSString *)kCGImagePropertyExifDateTimeOriginal];
CFRelease(props);
CFRelease(myImageSource);
NSString *path = [[NSBundle mainBundle] pathForResource:@"IMG_0011" ofType:@"JPG"];
NSData *pngData = [NSData dataWithContentsOfFile:path];
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)pngData, NULL);
NSDictionary *metadata = CFBridgingRelease(CGImageSourceCopyPropertiesAtIndex(source, 0, NULL));
NSLog(@"exif %@" , metadata);
CFRelease(source);
请不要忘记“”,即核心基础与<代码>创建< /COD>或<代码>拷贝>代码>将其所有权转移给您,并且您负责释放这些对象。例如,您可以使用
\u桥接\u传输
或CfBridgegRelease
将源属性字典的所有权传输给ARC。您可以显式地CGImageSourceRef的CFRelease
我这样做,但仍然可以看到有限的exif数据。我下载到NSData容器中的图像是一个.THM文件。你知道我的问题是什么吗?