Retrieving the EXIF date/time from 250k images
site_archiver@lists.apple.com Delivered-To: cocoa-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=simple/simple; d=uni-bremen.de; s=2019; t=1660512138; i=@uni-bremen.de; bh=WVDMo9BkH5A9pSqilRDBQJjHJU4+hRwV9hbJjKjd314=; h=From:Date:To; b=sQh8gyp/GdSLxZuWUPhZzhf8pCstC1LQqYdrN8yQhHKTEYie0H0q9boVJ4ZnkHeYP dwlOki6BN6tc6GGjVMGuZWdZ4PaWaMlAjx0bQ/LAvLnMYptUMjbkImKtQM2kQlKYWV uHlQXHiRowPE2A3GUYMJbZsl4X8hwBLbD9+myxsMbCte39v+2x3f8vvcWxjsEThms0 u4NsXAivO+WoBBV7GmOO/Ie6XLdgZPjMvbrVnNf37foAUJzYHj4bafwK3rUxBBV3OZ UzPYIamjUwbGvGvG7d8UNmPHHAnVaGn/TPsU9P/ZzTshK+eCsly5LD6WampcPGcTtH oNhW8t9vwHTaw== I would like to collect the date/time stored in an EXIF tag in a bunch of images. I thought I could do so with the following procedure (some details and error checking omitted for sake of clarity): NSMutableArray * dates_and_times = [NSMutableArray arrayWithCapacity: [imagefiles count]]; CFDictionaryRef exif_dict; CFStringRef dateref = NULL; for ( NSString* filename in imagefiles ) { NSURL * imgurl = [NSURL fileURLWithPath: filename isDirectory: NO]; // escapes any chars that are not allowed in URLs (space, &, etc.) CGImageSourceRef image = CGImageSourceCreateWithURL( (__bridge CFURLRef) imgurl, NULL ); CFDictionaryRef fileProps = CGImageSourceCopyPropertiesAtIndex( image, 0, NULL ); bool success = CFDictionaryGetValueIfPresent( fileProps, kCGImagePropertyExifDictionary, (const void **) & exif_dict ); success = CFDictionaryGetValueIfPresent( exif_dict, kCGImagePropertyExifDateTimeDigitized, (const void **) & dateref ); NSString * date_str = [[NSString alloc] initWithString: (__bridge NSString * _Nonnull)( dateref ) ]; NSDate * iso_date = [isoDateFormatter_ dateFromString: date_str]; if ( iso_date ) [dates_and_times addObject: iso_date ]; CFRelease( fileProps ); } But, I get the impression, this code actually loads each and every image. On my Macbook, it takes 3m30s for 250k images (130GB). So, the big question is: can it be done faster? I know the EXIF tags are part of the image file, but I was hoping it might be possible to load only those EXIF dictionaries. Or are the CGImage functions above already clever enough to implement this idea? Best regards, Gab. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com smime.p7s
participants (1)
-
Gabriel Zachmann via Cocoa-dev