Saturday, July 4, 2009

Batch converting photos using Imagemagick

Our store has a 7-inch photo frame, with a 2GB stick in it. So we can just drag-and-drop lots of photos onto the stick.

But how can we use Imagemagick, the command-line photo editor, to batch-resize a whole bunch of images...perhaps as part of a script?

Here's one way to resize a single photo:
$ mogrify -sample 480 foldername/filename.jpg

Here's one way to resize a whole directory of files from 4000 x 3000 to 400 x 300.
$ mogrify -sample 400 foldername/*.jpg

This resizes the original(s). Making copies (before the resize) is a separate command:
$ mkdir copies
$ cp original/image.jpg copies/
$ mogrify -sample 400 copies/image.jpg
$ mv copies/image.jpg stick/

No comments: