Batch image resize using linux command line


#1

Transfered from Linux Config Disqus comments:

Question:
How can I batch resize of multiple images using ubuntu linux command line? Is there any tool which would help me with this and/or is there GUI application which makes image resizing easy. I have hundreds of images and therefore I’m in need of such a tool.
Answer:
The best and the easiest way to resize multiple images using linux command line is to use imagemagick tools. First you need to install imagemagick package:

# apt-get install imagemagick 

Once installed you will have multiple image processing tools available to our disposal, such as convert, identify and etc.

identify command will help you to get some image information and convert will help you to convert images between hundreds of different image formats as well as it will easily resize any image submitted as an argument. Let’s suppose that our current working directory contains multiple image files with extension *.jpg . To resize all images to a half size of their original size we can combine bash for loop and convert command together in a following manner:

$ for i in $( ls *.jpg); do convert -resize 50% $i re_$i; done 

The command above will resize all images to half of its original size. New resized images will be saved with a prefix “re_”. It is also possible to resize all images and at the same time convert them to gif format:

$ for i in $( ls *.jpg); do convert -resize 50% $i $i.gif; done 

When it comes to GUI application which are able of batch image resizing you might look at Converseen .


#2