Monday 26 May 2014

Batch operations on images

Recently I've found myself in need of doing some batch operations to a couple of icons. I've noticed as well I need to do something like this every now and then. Frequently enough to have a set of tools for that.

Previously I've used GIMP with a Batch Process plugin (free with UI integrated into GIMP: http://registry.gimp.org/node/20893). Unfortunately the plugin doesn't have the functionality I needed last time.

This is where I found ImageMagick:
http://www.imagemagick.org/

It's a pretty cool app. With several batch commands I can do batch operations on the icons:

    Change transparent background of all .png images in the app's folder to snow2 colour ( bright grey )
    mogrify -path D:\new -background snow2 -flatten -format "_snow2.png" *.png

    Change transparent background of all .png images in the app's folder to white colour
    mogrify -path D:\new -flatten -format "_white.png" *.png

    Resize all images to the resolution 76 x 76.
    mogrify -path D:\new -sharpen 0x1.2 -quality 95 -resize 76x76 -format "_r76.png" *.png

All of the commands above copy the result to D:\new folder. They add appropriate endings to output file names ( for instance _r76.png ).