14 Jun 2008

Batch resize images using ImageMagick

Resizing images is a task I had to do several times through time and usually I use Gimp for the task, however, doing it for hundreds of different files would be very painful without some kind of batch process to do it.
That's why I use one of the many functionalities ImageMagick provides.

Those using Ubuntu (like I do) can install ImageMagick like this:
# sudo apt-get install imagemagick

So what I usually do when I want to resize a group of images to a specific size is move them together into the same directory and then:

# mogrify -resize 1024x768 *

This command just replaces all the images found with the resized ones. Note that it does not change the original aspect ratio so it's not guaranteed that you'll get 1024x768.
If you really want to convert the images to a specific size, regardless of it's aspect ratio then you just add a question mark to the previous command like this:

# mogrify -resize 1024x768! *

No comments: