b-r*_*yce 1 macos objective-c libexif
我是Objective-C的新手,我正试图在我的Mac OS应用程序中获取某些图像的exif数据.看起来我需要一个C库来获取exif数据,所以我google了一下,找到了一些C库,但我正在努力实现它们.
1我是否需要获取C库才能读取从DSLR相机拍摄的图像上的exif数据?(就像约会日期一样)
我尝试了这个库http://libexif.sourceforge.net/,我在网站上挖掘并从这里下载:http://www.hmug.org/pub/MacOS_X/BSD/Libraries/Graphics/libexif/,转到此链接:http://www.hmug.org/pub/MacOS_X/BSD/Libraries/Graphics/libexif/libexif-0.6.21-1-osx8.tar.gz
我把这些文件打包成xcode,看起来文件正确地添加到我的库中,我想.
我现在不确定如何使用这些C类.我尝试包含这样的文件
#include "exif-data.h"
#include "exif-loader.h"
这是正确的吗?我应该采取不同的方式吗?
使用libexif的应用程序通常会首先创建一个ExifLoader来将EXIF数据加载到内存中.从那里,它将提取数据作为ExifData开始操纵它.每个IFD由ExifData中的自己的ExifContent表示,其中包含ExifEntry形式的所有标记数据.如果需要MakerNote数据,可以从ExifData中提取ExifMnoteData并使用MakerNote函数进行操作.
"创建ExifLoader"的语法是什么?
对不起,这是一个菜鸟问题!任何帮助表示赞赏.
您可以使用Apples自己的API来获取图像Exif.
这是一个 CGImageSource Reference 和CGimageProperties
她是一个简单的例子:
NSURL *imageFileURL = [NSURL fileURLWithPath:@"/Users/USERNAME/Documents/tasting_menu_004.jpg"];
CGImageSourceRef imageSource = CGImageSourceCreateWithURL((CFURLRef)imageFileURL, NULL);
NSDictionary *treeDict;
NSMutableString *exifData;
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:NO], (NSString *)kCGImageSourceShouldCache,
nil];
CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, ( CFDictionaryRef)options);
CFRelease(imageSource);
if (imageProperties) {
treeDict = [NSDictionary dictionaryWithDictionary:(NSDictionary*)(imageProperties)];
id exifTree = [treeDict objectForKey:@"{Exif}"];
exifData = [NSMutableString stringWithString:@""];
for (NSString *key in [[exifTree allKeys] sortedArrayUsingSelector:@selector(compare:)])
{
NSString* locKey = [[NSBundle bundleWithIdentifier:@"com.apple.ImageIO.framework"] localizedStringForKey:key value:key table: @"CGImageSource"];
id value = [exifTree valueForKey:key] ;
[exifData appendFormat:@"key =%@ ; Value = %@ \n", locKey,value];
}
NSLog(@" exifData %@", exifData);
Run Code Online (Sandbox Code Playgroud)
日志 - > exifData
key =光圈值; 值= 4.643856
key =色彩空间; 值= 65535
key =自定义渲染; 值= 0
key =数字化日期时间; Value = 2013:06:13 08:35:07
key =日期时间原件; Value = 2013:06:13 08:35:07
key = Exif版本; 值=(2,2,1)
key =暴露偏差值; 值= 0
key =曝光模式; 值= 1
key =暴露计划; 值= 1
key =曝光时间; 值= 0.0125
key = FNumber; 值= 5
key = Flash; 值= 9
key =焦距; 值= 17
key =焦平面分辨率单位; 值= 2
key =焦平面X分辨率; 值= 3849.211788896504
key =焦平面Y分辨率; 值= 3908.141962421712
key = ISO Speed Ratings; 值=(800)
key =最大孔径值; 值= 4
key =计量模式; 值= 5
key = Pixel X Dimension; 值= 5181
key = Pixel Y Dimension; 值= 3454
key =场景捕捉类型; 值= 0
key =快门速度值; 值= 6.321928
key =主题距离; 值= 1.22
key =亚秒级数字化时间; 值= 25
key =亚秒时间原始; 值= 25
key =白平衡; 值= 0
| 归档时间: |
|
| 查看次数: |
3579 次 |
| 最近记录: |