Wednesday, October 17, 2012

Lazy batch resize of jpeg pictures using ImageMagick

The suite ImageMagick provides a tool called convert that will help us to do the trick.

-rwx------ 1 amartin amartin 1.3M Oct 17 14:00 IMAG0315.jpg
$ convert IMAG0315.jpg -density 36 -geometry 40x40% IMAG0315.jpeg
$ ls -lh IMAG0315.jpeg
-rw-r--r-- 1 amartin amartin 301K Oct 17 14:00 resize/IMAG0315.jpeg

If we want to reside a batch of files, whiting the same directory, we can use the following command to convert all the .jpg files to reduces .jpeg:

$ for file in `ls -1 *.jpg| cut -d '.' -f 1`; do convert $file.jpg -density 36 -geometry 40x40% $file.jpeg; done

No comments:

Post a Comment