Monday, 10 September 2012

Letting ImageMagick do the heavy lifting

Sometimes, as the files from our digital cameras get ever larger, we find that we don't need such huge files, and need to make a set of smaller images. Think of it as a set of proof-prints for the post-film world.

There are plenty of applications which will do this - iPhoto, Picasa and any number of things supplied with the camera. Trouble here is that the GUI is not really necessary in this case. There will be some performance penalty to be paid for loading thumbnails of the images, and it is likely to be a more than one-click operation.

If you know exactly what you want to do, then this is more easily accomplished in ImageMagick. For instance, I have recently had the need to perform the following steps, repeatedly on several sets of images:
  • Get the image from a locally mounted server directory
  • Make a copy
  • Resize the copy and drop the JPEG quality a bit
  • Turn it upside down
  • Save it into a new folder
To do this in ImageMagick is simple. Unusually for me, this example is in DOS, but a *NIX version would be much the same. In the directory where your original files are held:

for %A in (dir *.JPG) do convert -resize 1500x1500 -rotate 180 -quality 70 -verbose "%A" "path\to\the\resized\images\%A"

And then hit return. Quoting out the paths helps with images with spaces in the names, and the "verbose" switch ensures you have some output on screen. 

No comments:

Post a comment