Thank you.
Maybe it’s because insomnia strikes but I am surprised because, in www.mac.osxautomation.com I may read :
The Image Events application is used by AppleScript to control the SIPS architecture. It has no visual interface and presents no menus, windows, or dialogs for user interaction. It is intended to run invisibly as a background process, only accessible via AppleScript commands.
So I always thought that Image Events was able to do what SIPS does.
Here the script below grabs the size infos from a file stored on an external device using Image Events as well as extracting metadatas with ASObjC.
----------------------------------------------------------------
use AppleScript version "2.5" -- (10.11) or later
use framework "Foundation"
use scripting additions
----------------------------------------------------------------
set theFile to choose file of type {"public.png", "public.jpeg"}
set theFile to theFile as «class furl»
set POSIXPath to POSIX path of theFile
log POSIXPath -- to check that it's on an external device
tell application "Image Events"
try
set openedFile to open theFile -- a «class furl» object
properties of openedFile
close openedFile
end try
try
set openedFile2 to open POSIXPath -- a POSIX Path
properties of openedFile2
close openedFile2
end try
end tell
set thisNSURL to current application's NSURL's fileURLWithPath:POSIXPath
set nsMetaItem to current application's NSMetadataItem's alloc()'s initWithURL:thisNSURL
# Build a list of every available metadatas
set theMetadata to nsMetaItem's valuesForAttributes:(nsMetaItem's attributes())
return theMetadata as list
Here, under 10.13.6, the log history is :
tell application "Script Editor"
choose file of type {"public.png", "public.jpeg"}
--> alias "Aluice_250:Users:**********:DiskSpeedTest.png"
end tell
(*/Volumes/Aluice_250/Users/**********/DiskSpeedTest.png*)
tell application "Image Events"
open file "Aluice_250:Users:**********:DiskSpeedTest.png"
--> image "DiskSpeedTest.png"
get properties of image "DiskSpeedTest.png"
--> {color space:RGB, image file:file "Aluice_250:Users:**********:DiskSpeedTest.png", bit depth:millions of colors,
dimensions:{825, 850},
location:folder "Aluice_250:Users:**********:", embedded profile:missing value, file type:PNG, class:image, name:"DiskSpeedTest.png", resolution:{72.0, 72.0}}
close image "DiskSpeedTest.png"
open "/Volumes/Aluice_250/Users/**********/DiskSpeedTest.png"
--> image "DiskSpeedTest.png"
get properties of image "DiskSpeedTest.png"
--> {color space:RGB, image file:file "Aluice_250:Users:**********:DiskSpeedTest.png", bit depth:millions of colors,
dimensions:{825, 850},
location:folder "Aluice_250:Users:**********:", embedded profile:missing value, file type:PNG, class:image, name:"DiskSpeedTest.png", resolution:{72.0, 72.0}}
close image "DiskSpeedTest.png"
end tell
Résultat :
{{kMDItemFSContentChangeDate:date "lundi 11 avril 2011 à 22:57:31", kMDItemDateAdded_Ranking:date "mardi 9 décembre 2014 à 01:00:00", kMDItemFSTypeCode:0,
kMDItemPixelHeight:850,
kMDItemDisplayName:"DiskSpeedTest.png", kMDItemFSIsExtensionHidden:false, kMDItemFSLabel:0, kMDItemContentCreationDate:date "lundi 11 avril 2011 à 22:57:31", kMDItemContentTypeTree:{"public.png", "public.image", "public.data", "public.item", "public.content"}, kMDItemBitsPerSample:40, kMDItemInterestingDate_Ranking:date "lundi 11 avril 2011 à 02:00:00", kMDItemFSFinderFlags:0, kMDItemPixelCount:701250, kMDItemHasAlphaChannel:true, kMDItemResolutionHeightDPI:72, kMDItemFSSize:364246, kMDItemColorSpace:"RGB", kMDItemFSName:"DiskSpeedTest.png", kMDItemDateAdded:date "mardi 9 décembre 2014 à 20:16:50", kMDItemResolutionWidthDPI:72, kMDItemPhysicalSize:364544, kMDItemFSCreationDate:date "lundi 11 avril 2011 à 22:57:31", kMDItemContentCreationDate_Ranking:date "lundi 11 avril 2011 à 02:00:00", kMDItemFSCreatorCode:0, kMDItemInterestingDate_RankingRepaired:true, kMDItemOrientation:1, kMDItemFSInvisible:false, kMDItemKind:"Image PNG (Portable Network Graphics)",
kMDItemPixelWidth:825,
kMDItemFSOwnerUserID:501, kMDItemContentModificationDate:date "lundi 11 avril 2011 à 22:57:31", kMDItemContentType:"public.png", kMDItemLogicalSize:364246, kMDItemFSOwnerGroupID:20}}
I was aware that under Catalina, Image Events has problem with alias objects but not that it’s failing with files stored on external devices.
If it’s confirmed, it seems that it’s not a feature but an annoying bug.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 22 mai 2020 03:49:13