Ever need to automate changes to image files? Maybe a LaunchAgent that would watch a specific folder and resize png files that were dropped in there, or a little script that sanitized images as they came in to be a specific size (e.g. Poster Frames)? Well, sips is a little tool built into OS X that can help immensely with this. It will even convert that png to a jpeg or pict to png. Let’s look at using sips. First up, let’s just get the width and height of an image file:
sips --getProperty pixelHeight /Shared/tmpimages/1.png
sips --getProperty pixelWidth /Shared/tmpimages/1.png
Or for dpi:
sips --getProperty dpiHeight /Shared/tmpimages/1.png
sips --getProperty dpiWidth /Shared/tmpimages/1.png
Or to get the format:
sips --getProperty format Shared/tmpimages/1.png
Now let’s set the property, where the property is format, using the -o option to output a copy of the file to different location:
sips --setProperty format jpeg /Shared/tmpimages/1.png -o /Shared/imageoutput/1.jpeg
Pretty nifty so far. Now, let’s resize an image using the -z option:
sips /Shared/tmpimages/1.png -z 44 70 -o /Shared/imageoutput/converted.png
There’s lots more you can do with sips. It also happens to be built into OS X in the /usr/bin folder. Call on it for general still image manipulation. It’s quick and easily scriptable and best of all, a useful tool that can save lots of manual time converting images.