AppleScript "Image Events" does no longer get all Metadata

Using a simple script to get the EXIF-information from a photo

tell application "Image Events"
	set theOpenFile to open "/PATH/TO/IMAGE.HEIC"
	set theTags to name of metadata tags of theOpenFile
	close theOpenFile
	return theTags
end tell

I get for the same image (from an iPhone) following results

macOS 13.2

{"format", "hasAlpha", "formatOptions", "typeIdentifier", "dpiHeight", "dpiWidth", "path"}

macOS 10.14.6 (Mojave)

{"samplesPerPixel", "hasAlpha", "dpiHeight", "dpiWidth", "bitsPerSample", "profile", "formatOptions", "ExifColorSpace", "pixelHeight", "path", "creation", "software", "space", "pixelWidth", "format", "make", "model", "typeIdentifier"}

So it is no longer possible to read the image meta data using AppleScript on macOS Ventura, i.e. the creation date.

I did another test using a small sample based on https://stackoverflow.com/questions/18265760/get-exif-data-in-mac-os-development. I wrote a simple console App with following code:

#import <Foundation/Foundation.h>
#import <ImageIO/ImageIO.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        NSURL *imageFileURL = [NSURL fileURLWithPath: [@"~/Desktop/IMG_1845.HEIC" stringByStandardizingPath]];
        CGImageSourceRef imageSource = CGImageSourceCreateWithURL((CFURLRef)imageFileURL, NULL);
        NSDictionary *treeDict;
        NSMutableString *exifData;
        NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:NO],
                                (NSString *)kCGImageSourceShouldCache, nil];
        CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, ( CFDictionaryRef)options);
        CFRelease(imageSource);
        if (imageProperties) {
            treeDict = [NSDictionary dictionaryWithDictionary:(__bridge NSDictionary*)(imageProperties)];
            id exifTree = [treeDict objectForKey:@"{Exif}"];
            exifData = [NSMutableString stringWithString:@""];

            for (NSString *key in [[exifTree allKeys] sortedArrayUsingSelector:@selector(compare:)])
            {
                NSString* locKey = [[NSBundle bundleWithIdentifier:@"com.apple.ImageIO.framework"] localizedStringForKey:key value:key table: @"CGImageSource"];
                id  value = [exifTree  valueForKey:key];
                [exifData appendFormat:@"key =%@ ; Value = %@ \n", locKey,value];
            }
            NSLog(@" exifData %@", exifData);
        }
        return 0;
    }
}

On macOS 14.6 I get following output:

$ ./exifTest 
2023-01-25 09:44:32.532 exifTest[2409:21024]  exifData key =Aperture Value ; Value = 1.169925002106682 
key =Brightness Value ; Value = 4.710561089652368 
key =Color Space ; Value = 65535 
key =Date Time Digitized ; Value = 2022:10:27 16:31:42 
key =Date Time Original ; Value = 2022:10:27 16:31:42 
key =Digital Zoom Ratio ; Value = 1.2096 
key =Exif Version ; Value = (
    2,
    3,
    2
) 
key =Exposure Bias Value ; Value = 0 
key =Exposure Mode ; Value = 0 
key =Exposure Program ; Value = 2 
key =Exposure Time ; Value = 0.00684931506849315 
key =FNumber ; Value = 1.5 
key =Flash ; Value = 16 
key =Focal Length In 35mm Film ; Value = 31 
key =Focal Length ; Value = 5.7 
key =ISO Speed Ratings ; Value = (
    64
) 
key =Lens Make ; Value = Apple 
key =Lens Model ; Value = iPhone 14 back dual wide camera 5.7mm f/1.5 
key =Lens Specification ; Value = (
    "1.54",
    "5.7",
    "1.5",
    "2.4"
) 
key =Metering Mode ; Value = 5 
key =Pixel X Dimension ; Value = 4032 
key =Pixel Y Dimension ; Value = 3024 
key =Scene Type ; Value = 1 
key =Sensing Method ; Value = 2 
key =Shutter Speed Value ; Value = 7.185264202431158 
key =Subject Area ; Value = (
    2016,
    1508,
    2319,
    1327
) 
key =Sub-second Time Digitized ; Value = 305 
key =Sub-second Time Original ; Value = 305 
key =White Balance ; Value = 0 

on macOS 13.2 I get

$ ./exifTest
2023-01-25 09:37:19.219 exifTest[21828:415974]  exifData key =(null) ; Value = 1.169925002106682 
key =(null) ; Value = 4.710561089652368 
key =(null) ; Value = 65535 
key =(null) ; Value = 2 
key =(null) ; Value = 2022:10:27 16:31:42 
key =(null) ; Value = 2022:10:27 16:31:42 
key =(null) ; Value = 1.2096 
key =(null) ; Value = (
    2,
    3,
    2
) 
key =(null) ; Value = 0 
key =(null) ; Value = 0 
key =(null) ; Value = 2 
key =(null) ; Value = 0.00684931506849315 
key =(null) ; Value = 1.5 
key =(null) ; Value = 16 
key =(null) ; Value = 31 
key =(null) ; Value = 5.7 
key =(null) ; Value = (
    64
) 
key =(null) ; Value = Apple 
key =(null) ; Value = iPhone 14 back dual wide camera 5.7mm f/1.5 
key =(null) ; Value = (
    "1.54",
    "5.7",
    "1.5",
    "2.4"
) 
key =(null) ; Value = 5 
key =(null) ; Value = +02:00 
key =(null) ; Value = +02:00 
key =(null) ; Value = +02:00 
key =(null) ; Value = 4032 
key =(null) ; Value = 3024 
key =(null) ; Value = 1 
key =(null) ; Value = 2 
key =(null) ; Value = 7.185264202431158 
key =(null) ; Value = (
    2016,
    1508,
    2319,
    1327
) 
key =(null) ; Value = 305 
key =(null) ; Value = 305 
key =(null) ; Value = 0 

So it seems that the EXIF keys are no longer provided from the OS!

I checked .heic images on my Mac mini M1 (macOS 13.3beta) by using your script.

One heic images returns {"samplesPerPixel", "hasAlpha", "dpiHeight", "dpiWidth", "space", "bitsPerSample", "formatOptions", "pixelHeight", "profile", "path", "pixelWidth", "format", "typeIdentifier"}

But most of images returns {"samplesPerPixel", "hasAlpha", "dpiHeight", "dpiWidth", "bitsPerSample", "profile", "formatOptions", "ExifColorSpace", "pixelHeight", "path", "creation", "software", "space", "pixelWidth", "format", "make", "model", "typeIdentifier"}

So, I don't think Image Events can not read "creation" Exif value. Today macOS has various bugs everywhere. Importer program is doubtful.

The heic image which returns {"samplesPerPixel", "hasAlpha", "dpiHeight", "dpiWidth", "space", "bitsPerSample", "formatOptions", "pixelHeight", "profile", "path", "pixelWidth", "format", "typeIdentifier"} did not return creation date by another AppleScript execution.

-- Created 2014-12-14 by Takaaki Naganoya
-- 2014 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use BPlus : script "BridgePlus" --https://www.macosxautomation.com/applescript/apps/BridgePlus.html

property NSString : a reference to current application's NSString
property NSLocale : a reference to current application's NSLocale
property SMSForder : a reference to current application's SMSForder
property NSDateFormatter : a reference to current application's NSDateFormatter


set aTargFile to choose file of type {"public.image"}
set exifRes to readExifDateTimeOriginal(aTargFile) of me


--指定ファイルからのExifデータを取得し撮影日付を取得する
on readExifDateTimeOriginal(aTargFileAlias)
	set theMetadata to readMetadataFrom(aTargFileAlias) of me
	set keysList to theMetadata's allKeys()
	
	if "{Exif}" is not in (keysList as list) then return false
	
	set exifDate to theMetadata's valueForKeyPath:"{Exif}.DateTimeOriginal"
	if exifDate = missing value then return false
	
	set fullDate to dateFromStringWithDateFormat(exifDate, "yyyy:MM:dd HH:mm:ss") of me
	
	return fullDate
end readExifDateTimeOriginal


--指定ファイルからのメタデータ読み込み
on readMetadataFrom(imageFile)
	load framework
	set {theRecord, theError} to SMSForder's metadataFromImage:imageFile |error|:(specifier)
	if theRecord = missing value then -- there was a problem, so extract the error description
		error (theError's localizedDescription() as text) -- number (theError's code())
	else
		return theRecord
	end if
end readMetadataFrom


--日付文字列を形式指定しつつdate objectに変換
on dateFromStringWithDateFormat(dateString, dateFormat)
	set dStr to NSString's stringWithString:dateString
	set dateFormatStr to NSString's stringWithString:dateFormat
	
	set aDateFormatter to NSDateFormatter's alloc()'s init()
	aDateFormatter's setDateFormat:dateFormatStr
	aDateFormatter's setLocale:(NSLocale's alloc()'s initWithLocaleIdentifier:"en_US_POSIX")
	
	set aDestDate to (aDateFormatter's dateFromString:dStr)
	
	return aDestDate as any
end dateFromStringWithDateFormat

AppleScript "Image Events" does no longer get all Metadata
 
 
Q