Wednesday, November 13, 2013

How to batch change image dpi resolution with imagemagick convert and bash

It is often useful to manipulate a lot (a lot!!!) of images the batch way. For today homework we are going to use imagemagick convert, a wonderful little tools, along with bash. In our case we are going to take a bunch of *.png images, and to change their resolution to 600 dpi. For this we are going to use a bash loop plus imagemagick convert with the -unit PixelPerInch and -density 600 options. The command is as simple as:

for f in path/from/*.png; \ 
do convert -units PixelsPerInch $f -density 600 path/to/$f ; done

Of course the same command line can be used to do much more than changing the resolution by feeding different options to the convert command line utility.

No comments:

Post a Comment