I’m puzzled.
Usually my preferred method to extract measurements of pictures (width and hight) was to invoke sips.
For some time now, I didn’t see, but only sporadic, that the width and hight values weren’t in the right sequence, hight was measured as width, width measured as hight. Maybe because sips was reading data from the picture’s original orientation shot with the camera ?
I don’t know, as most of the pictures in Finder have the right hight and width, interrogating sips.
Only some picture files in sips have exchanged measures.
Now, I tried another approach and used mdls instead.
Result : sips was wrong and mdls right.
Finally, I’d like to know if the fault is mine or if mdls is the better way to extract info? Thanks for any suggestion
tell application "Finder" to set sel to item 1 of (get the selection) as text
#set {H, W} to {word 2 of item 1, word 2 of item 2} of paragraphs of (do shell script "sips -g pixelHeight -g pixelWidth '" & POSIX path of sel & "' | tail -2")
set {H, W} to {word -1 of item 1, word -1 of item 2} of paragraphs of (do shell script "mdls -name kMDItemPixelHeight -name kMDItemPixelWidth " & POSIX path of sel)
log {H, W}
Some output I get :
tell current application
do shell script "sips -g pixelHeight -g pixelWidth '/Users/home/Pictures/IMG_6999.jpg' | tail -2"
--> " pixelHeight: 3456\r pixelWidth: 5184"
(*3456, 5184*)
do shell script "mdls -name kMDItemPixelHeight -name kMDItemPixelWidth /Users/home/Pictures/IMG_6999.jpg"
--> "kMDItemPixelHeight = 5184\rkMDItemPixelWidth = 3456"
(*5184, 3456*)
end tell