2012-08-07 3 views

답변

6

가져 ImageIO에서 프레임 워크와 타임 스탬프 이미지와보십시오. 여기에 one이 있으니 프로젝트에 추가하십시오.

#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); 
+0

이미 객체로 이미지가 있으므로 코드의 주석 처리 된 부분의 마지막 두 줄만 사용했습니다. 아키텍처 i386을위한 정의되지 않은 심볼 :이 (__bridge CFDataRef)에 (CFDataRef를) 전환하라고 내가 있음을했을 때 내가 말하는 rumtime 오류를 어디서 얻었 그러나 은 엑스 코드는 나에게 오류를 제공 *에서 대부분의 기능 코드*. ld : 아키텍처 i386에 대한 기호가 없습니다. clang : 오류 : 링커 명령이 종료 코드 1 (호출을 보려면 -v 사용)에 실패했습니다. 그게 무슨 뜻입니까? – Tom

+0

대상에 ImageIO 프레임 워크를 추가해야합니다. http://stackoverflow.com/questions/3352664/how-to-add-existing-frameworks-in-xcode-4 –

+0

죄송합니다. 느려졌습니다 ...하지만 얻습니다 : "exif dic에서 타임 스탬프를 찾을 수 없습니다" 내 모든 아이폰 사진에. 이 아이폰은 사진을 찍을 때 타임 스탬프를 만들지 않는 표준을 가지고 있습니까? – Tom

관련 문제