$ cat "

Batch Image Resize/Rotate in Ubuntu

"

Resizing and rotating images can be a really time consuming and boring task that just begs to be automated. If you are running Ubuntu, this is easily achieved by using Imagemagick.

To install imagemagick, just do an ordinary apt-get, like this:

sudo apt-get install imagemagick

Now you are ready to start batch processing your images. Here are some examples of useful commands:

To resize an image to a specific size:


convert foo.jpg -resize 640x480 foo2.jpg


To resize using a percentage:


convert foo.jpg -resize 50% foo2.jpg


To resize an image to a specific width, keeping aspect ratio:


convert foo.jpg -resize 640 foo2.jpg


To resize an image to a specific height, keeping aspect ratio:


convert foo.jpg -resize x480 foo2.jpg


To rotate an image:


convert foo.jpg -rotate 90 foo2.jpg


These commands can be chained together like so:


convert foo.jpg -rotate 90 -resize 640 foo2.jpg


To operate on multiple files, file globbing can be used, like this


convert *.jpg -rotate 90 -resize 500 rotated_%03d.jpg


The %03d means three incrementing digits. So in this example, the new file names will be rotated_000.jpg, rotated_001.jpg etc.

Written by Erik Öjebo 2008-12-05 09:35

    Comments