문제

I have a trouble. When i get date from image the value is NULL. imagePropertiesDictionary doesn't contain key kCGImagePropertyExifDateTimeOriginal. I was take this sample from Apple dev library.

CGImageSourceRef myImageSource;

myImageSource = CGImageSourceCreateWithURL(url, NULL);

CFDictionaryRef imagePropertiesDictionary;

imagePropertiesDictionary = CGImageSourceCopyPropertiesAtIndex(myImageSource,0, NULL);

NSString *dateTaken = (NSString *)CFDictionaryGetValue(imagePropertiesDictionary, kCGImagePropertyExifDateTimeOriginal);
NSLog(@"%@",dateTaken);

CFRelease(imagePropertiesDictionary);
CFRelease(myImageSource);

_textbox.stringValue = [NSString stringWithFormat:@"%@", dateTaken];
도움이 되었습니까?

해결책

You need to check the EXIF properties dictionary:

CFDictionaryRef props = CGImageSourceCopyPropertiesAtIndex(source, 0, NULL);
NSDictionary *exif = [(NSDictionary *)props objectForKey : (NSString *)kCGImagePropertyExifDictionary];
NSString *dateTimeString = [exif objectForKey:(NSString *)kCGImagePropertyExifDateTimeOriginal];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top