OS X: Getting Image-Dimensions on the Command-Line (sips)

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

  1. Posted March 9, 2008 at 11:01 am | Permalink

    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!

  2. Erik
    Posted March 28, 2008 at 10:43 am | Permalink

    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.

Post a Comment

Your email is never published nor shared. Required fields are marked *, comments are moderated.

*
*