default, superpanda, panda

Nifty command line tool of the day.

Originally published at You can comment here or there.

I’m putting together a web site which needs to have a portfolio of images on it. I want to do the standard thing where you have a thumbnail, and then click for the full sized image. But creating thumbnails is a pain in the ass, so I was looking at ways to do it in bulk, or at least to script it.

Using Preview to resize images wasn’t working out too well, because it seemed to randomly miss images in a select all, and then I’d have to hunt down the individual images that didn’t get resized, and blah blah blah. Commercial options are available, but damnit, this shouldn’t need a commercial option.

Turns out, it doesn’t.

Enter ‘sips’ (simple image processing system). To create thumbnails that are 240 pixels along the longest axis, the command was ridiculously simple:

sips -Z 240 *_thumb.jpg

The one downside is that it rewrites the source files, but a bit of planning ahead, and that’s not a problem.

Huzzah for UNIX!

Richard Rognlie liked this post
apropos: , ,
convert -geometry ${percent}x${percent} source.sfx dest.sfx
Yeah, I've been using convert for ages, too. I have a bourne shell script that scans through an entire directory of images, creates a Thumbnails subdir, then creates a thumbnail of each pic.


if [ ! -d Thumbnails ]; then
mkdir Thumbnails

for i in *.JPG;
if [ ! -f `basename $i .jpg`.jpg ]; then
mv $i `basename $i .JPG`.jpg

for i in *.jpg;

if [ ! -f Thumbnails/`basename $i .jpg`-sm.jpg ]; then
echo convert: $i
convert -interlace partition -size 64x64 JPEG:$i Thumbnails/`basename $i .jpg`-sm.jpg