I just wondered whether there is a way of getting a timestamp of a picture, or if that info even gets written to an image file, in example from when it was taken.
Thanks in advance
I just wondered whether there is a way of getting a timestamp of a picture, or if that info even gets written to an image file, in example from when it was taken.
Thanks in advance
 
    
    Import the imageIO framework and try with an image with a timestamp. Here is one, add it to your project.
#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);
