Resizing images - the Linux way

You can always re-size an image by opening up an image editor like Photoshop or Gimp. What if you have tens or hundreds of images to be re-sized? If you have ever dipped your toes in the Linux/Unix world, you would be thinking about automation. Here is something to start with.

I use Ubuntu but you can use any flavor of Linux. Install the Imagemagick, if you don't have it already. In Ubuntu, you would do

sudo apt-get install imagemagick

This would install a bunch of commands. If you are really curious to know what those commands are, try

sudo dpkg -L imagemagick

For resizing an image, we are interested in the command convert. The following command will take images from your current directory, re-size and put them under the 24x24 directory. In this example, we are resizing all images to 24x24 pixels.

find . -maxdepth 1 -name "*.png" -print -exec convert "{}" -resize 24x24 "24x24/ {}" \;

Wanna do more with your images? Get all the "juicy" details by running "man convert".

(Thanks to this blog for giving me the original idea)

Comments