Third party cookies may be stored when visiting this site. Please see the cookie information.

Batch resizing images on Linux or Windows - ImageMagick convert command

With the resolution of today's digital cameras it is often necessary to resize the files to make them smaller. You may want to reduce the file size before publishing them on the web, or sending in an email. When you have one or two images then it's not a problem.

Just load the file into the GIMP photo editor (for Linux or Windows), or Windows Vista users can use Microsoft Paint (although not on Windows XP or earlier).

If however you have a large number of images then this can get a bit tedious manually applying this to each one. There is however the convert command which is part of the ImageMagick suite. If you are running Linux then you most likely have that installed already, just man convert for more information. Windows users will have to install Cygwin - makes various Linux programs available for Windows. Download the Cygwin Setup Program and tick ImageMagick during the package selection. Once installed you can then run the Cygwin Bash Shell terminal and then enter the Linux commands into that screen.

The most basic way to use convert is to give a file at a time on the command line:

convert -resize 33% original.jpg newfile.jpg

Alternatively you could replace the percentage with the actual size such as 800x600

Where this really comes into it's own is when you have a directory full of images that you want to convert. This can be used by using the xargs and find commands in conjunction with convert.

find . -iname "*.jpg" | xargs -l -i convert -resize 800x600 {} ../small/{}


» PenguinTutor Facebook page