Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 获得;时间戳;从图像_Objective C_Ios - Fatal编程技术网

Objective c 获得;时间戳;从图像

Objective c 获得;时间戳;从图像,objective-c,ios,Objective C,Ios,我只是想知道是否有一种方法可以获取图片的时间戳,或者该信息是否会被写入到图像文件中,例如从拍摄时开始 提前感谢导入imageIO框架并尝试使用带有时间戳的图像。这是,将其添加到您的项目中 #import <ImageIO/ImageIO.h> NSString *path = [[NSBundle mainBundle] pathForResource:@"gg_gps" ofType:@"jpg"]; NSURL *imageFileURL = [NSURL fileURLWit

我只是想知道是否有一种方法可以获取图片的时间戳,或者该信息是否会被写入到图像文件中,例如从拍摄时开始


提前感谢

导入imageIO框架并尝试使用带有时间戳的图像。这是,将其添加到您的项目中

#import <ImageIO/ImageIO.h>

NSString *path = [[NSBundle mainBundle] pathForResource:@"gg_gps" ofType:@"jpg"];
NSURL *imageFileURL = [NSURL fileURLWithPath:path];
CGImageSourceRef imageSource = CGImageSourceCreateWithURL((CFURLRef)CFBridgingRetain(imageFileURL), NULL);

// or you can get your imageSource this other way:
// NSData *data =  [NSData dataWithContentsOfFile:path];
// CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL);

NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:NO], (NSString *)kCGImageSourceShouldCache, nil];
CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, (CFDictionaryRef)CFBridgingRetain(options));
CFDictionaryRef exifDic = CFDictionaryGetValue(imageProperties, kCGImagePropertyExifDictionary);
if (exifDic){
    NSString *timestamp = (NSString *)CFBridgingRelease(CFDictionaryGetValue(exifDic, kCGImagePropertyExifDateTimeOriginal));
    if (timestamp){
        NSLog(@"timestamp: %@", timestamp);
    } else {
        NSLog(@"timestamp not found in the exif dic %@", exifDic);
    }
} else {
    NSLog(@"exifDic nil for imageProperties %@",imageProperties);
}
CFRelease(imageProperties);
#导入
NSString*path=[[NSBundle mainBundle]pathForResource:@“gg_gps”类型:@“jpg”];
NSURL*imageFileURL=[NSURL fileURLWithPath:path];
CGImageSourceRef imageSource=CGImageSourceCreateWithURL((CFURLRef)CfBrigingRetain(imageFileURL),NULL);
//或者,您可以通过其他方式获取图像源:
//NSData*data=[NSData dataWithContentsOfFile:path];
//CGImageSourceRef imageSource=CGImageSourceCreateWithData((u桥CFDataRef)数据,NULL);
NSDictionary*选项=[NSDictionary Dictionary WithObjectsAndKeys:[NSNumber numberWithBool:NO],(NSString*)kCGImageSourceShouldCache,nil];
CFDictionaryRef imageProperties=CGImageSourceCopyPropertiesAtIndex(imageSource,0,(CFDictionaryRef)CfBrigingRetain(选项));
CFDictionaryRef exifDic=CFDictionaryGetValue(imageProperties,kCGImagePropertyExifDictionary);
if(exifDic){
NSString*时间戳=(NSString*)CfBrigingRelease(CFDictionaryGetValue(exifDic,kCGImagePropertyExifDateTimeOriginal));
if(时间戳){
NSLog(@“时间戳:%@”,时间戳);
}否则{
NSLog(@“在exif dic中未找到时间戳%@”,exifDic);
}
}否则{
NSLog(@“exifDic nil for imageProperties%@”,imageProperties);
}
CFRelease(imageProperties);

导入imageIO框架并尝试使用带有时间戳的图像。这是,将其添加到您的项目中

#import <ImageIO/ImageIO.h>

NSString *path = [[NSBundle mainBundle] pathForResource:@"gg_gps" ofType:@"jpg"];
NSURL *imageFileURL = [NSURL fileURLWithPath:path];
CGImageSourceRef imageSource = CGImageSourceCreateWithURL((CFURLRef)CFBridgingRetain(imageFileURL), NULL);

// or you can get your imageSource this other way:
// NSData *data =  [NSData dataWithContentsOfFile:path];
// CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL);

NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:NO], (NSString *)kCGImageSourceShouldCache, nil];
CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, (CFDictionaryRef)CFBridgingRetain(options));
CFDictionaryRef exifDic = CFDictionaryGetValue(imageProperties, kCGImagePropertyExifDictionary);
if (exifDic){
    NSString *timestamp = (NSString *)CFBridgingRelease(CFDictionaryGetValue(exifDic, kCGImagePropertyExifDateTimeOriginal));
    if (timestamp){
        NSLog(@"timestamp: %@", timestamp);
    } else {
        NSLog(@"timestamp not found in the exif dic %@", exifDic);
    }
} else {
    NSLog(@"exifDic nil for imageProperties %@",imageProperties);
}
CFRelease(imageProperties);
#导入
NSString*path=[[NSBundle mainBundle]pathForResource:@“gg_gps”类型:@“jpg”];
NSURL*imageFileURL=[NSURL fileURLWithPath:path];
CGImageSourceRef imageSource=CGImageSourceCreateWithURL((CFURLRef)CfBrigingRetain(imageFileURL),NULL);
//或者,您可以通过其他方式获取图像源:
//NSData*data=[NSData dataWithContentsOfFile:path];
//CGImageSourceRef imageSource=CGImageSourceCreateWithData((u桥CFDataRef)数据,NULL);
NSDictionary*选项=[NSDictionary Dictionary WithObjectsAndKeys:[NSNumber numberWithBool:NO],(NSString*)kCGImageSourceShouldCache,nil];
CFDictionaryRef imageProperties=CGImageSourceCopyPropertiesAtIndex(imageSource,0,(CFDictionaryRef)CfBrigingRetain(选项));
CFDictionaryRef exifDic=CFDictionaryGetValue(imageProperties,kCGImagePropertyExifDictionary);
if(exifDic){
NSString*时间戳=(NSString*)CfBrigingRelease(CFDictionaryGetValue(exifDic,kCGImagePropertyExifDateTimeOriginal));
if(时间戳){
NSLog(@“时间戳:%@”,时间戳);
}否则{
NSLog(@“在exif dic中未找到时间戳%@”,exifDic);
}
}否则{
NSLog(@“exifDic nil for imageProperties%@”,imageProperties);
}
CFRelease(imageProperties);

因为我已经将图像作为对象,所以我只使用了代码注释部分的最后两行。然而,xcode给了我一个错误,它告诉我将(CFDataRef)切换到(_桥CFDataRef),当我这样做时,我得到了一个很长的错误,说:架构i386的未定义符号:代码中的大部分函数。未找到体系结构i386的ld:symbol clang:error:linker命令失败,退出代码为1(使用-v查看调用)。这意味着什么?您需要将ImageIO框架添加到目标中。对不起,我太慢了。。。但我在我所有的iphone照片上都看到了:“exif dic中找不到时间戳”。这是否意味着iphone有一个标准,在拍照时不创建时间戳?我不知道。我发现:它可以测试你的照片,如果你展开描述,它将告诉你如何在照片中启用地理标记。因为我已经将图像作为对象,所以我只使用了代码注释部分的最后两行。然而,xcode给了我一个错误,它告诉我将(CFDataRef)切换到(_桥CFDataRef),当我这样做时,我得到了一个很长的错误,说:架构i386的未定义符号:代码中的大部分函数。未找到体系结构i386的ld:symbol clang:error:linker命令失败,退出代码为1(使用-v查看调用)。这意味着什么?您需要将ImageIO框架添加到目标中。对不起,我太慢了。。。但我在我所有的iphone照片上都看到了:“exif dic中找不到时间戳”。这是否意味着iphone有一个标准,在拍照时不创建时间戳?我不知道。我发现:它可以测试你的照片,如果你扩展描述,它会告诉你如何在照片中启用地理标记。