If you need to get the dimensions of an image-file via the command-line, let’s say in a script or an AppleScript, then there is a way to do so easily. Enter the scriptable image processing system or short sips. You didn’t know you got that installed on your OS X system alreay? Me neither.
Assume, that we need to get the dimensions of an image for further handling of said image. The command
sips -g pixelWidth -g pixelHeight [image-file]
returns the values (and a lot more if asked correctly).
Give it a try and take a look at the man-page (man sips) for further information. A really handy tool for all scripters.
2 Comments
Hi Erik,
I just wanted to add, that AppleScript has its own built-in sips-based scripting addition named Image Events.
Image Events is basically just a wrapper for sips. So when scripting in AppleScript, there is often no need to use sips via the «do shell script» command, you can just gain informations or manipulate images with Image Events.
Best regards from Germany!
Hi Martin,
thanks for the info. I wasn’t aware that “Image Events” is using sips.
BTW: Sorry for answering so late, I’ve been very busy the last couple of weeks.