Monday, October 28, 2013

Debian Wheezy: resize/scale images from command line.

First of all you need to have installed imagemagick.
If no, install it from terminal as root so:

apt-get install imagemagick

Now you are ready to convert input.jpg file into output.jpg file for a 1000 pixels of width and 500 pixels of height....

convert -scale 1000x500 input.jpg output.jpg 

The scale method, in this case, depends of the height and the weight of your image.
So if your image is 2 pixels of width and 1 pixels of height the perform will gone exactly.

Differently the perform will be approximated.

If you want to force the scale performing to make a image of gived dimensions...

convert -scale 1000x500! input.jpg output.jpg

If you have multiple files to convert use this:

for i in $( ls *.JPG); do convert -resize 1300x500 $i $i; done
 
Bye.

No comments:

Post a Comment