I'm working on a tool that will help my students understand image resolution in relation to page layout for print. One thing I need to do is find the pixel dimensions (width, height) of any given image file: JPEG, TIFF, PSD and other bitmap image formats.
I'm getting somewhere with AppleScript, although dealing with file paths across LC and AS is, er, 'interesting'
But is there a way to do this (find the pixel width and height of a given image file) natively in LC?
k
Dimensions of an image file?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 346
- Joined: Mon Mar 01, 2010 7:13 pm
- Location: London, UK
- Contact:
Dimensions of an image file?
Technical Writer, Meta
University Lecturer
Technical Editor, MacUser (1996-2015)
360 VR media specialist
University Lecturer
Technical Editor, MacUser (1996-2015)
360 VR media specialist
Re: Dimensions of an image file?
Hi Keith,
on the Mac you can use SIPS (Scriptable Image Processing System) with shell!
Use something like this to get the dimensions of any image:
Best
Klaus
on the Mac you can use SIPS (Scriptable Image Processing System) with shell!
Use something like this to get the dimensions of any image:
Code: Select all
on mouseUp
answer file "Select image..."
put QUOTE & it & QUOTE into tImage
get shell("sips -g pixelHeight" && tImage)
put last word of it into tHeight
get shell("sips -g pixelWidth" && tImage)
put last word of it into tWidth
answer "Image dimensions:" && tWidth & "," & tHeight
end mouseUp
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 346
- Joined: Mon Mar 01, 2010 7:13 pm
- Location: London, UK
- Contact:
Re: Dimensions of an image file?
Wow - when in doubt, shell.
I had a bit of a search for a CLI solution (honest, I did!) but I was too hung up on my 'close but no cigar' efforts with AppleScript. This is superb and easy to weave into my experiments – many thanks!
k
I had a bit of a search for a CLI solution (honest, I did!) but I was too hung up on my 'close but no cigar' efforts with AppleScript. This is superb and easy to weave into my experiments – many thanks!
k
Technical Writer, Meta
University Lecturer
Technical Editor, MacUser (1996-2015)
360 VR media specialist
University Lecturer
Technical Editor, MacUser (1996-2015)
360 VR media specialist
Re: Dimensions of an image file?
Hi Keith,
glad I could help!
And SIPS can do a lot more with images, see the MAN page here:
https://developer.apple.com/legacy/libr ... ips.1.html
And yes, AppleScripts SUCKS, hard to believe that HyperTalk was intended to be the first Scripting language for Mac OS, but then they chose AppleScript
Anyway, have a nice day!
Best
Klaus
glad I could help!
And SIPS can do a lot more with images, see the MAN page here:
https://developer.apple.com/legacy/libr ... ips.1.html
And yes, AppleScripts SUCKS, hard to believe that HyperTalk was intended to be the first Scripting language for Mac OS, but then they chose AppleScript
Anyway, have a nice day!
Best
Klaus