Question

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];
Was it helpful?

Solution

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];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top