> Create fixed size thumbnails with ImageMagick
ImageMagick is powerful suite of applications to create, edit, convert and compose bitmap (and some vector) images from the terminal. It’s an essential tool for any web designer if you can get your head around it.
Photoshop has a nice Batch tool but it’s extremely slow if you have to deal with thousands images. A common task is to create thumbnails from a set of pictures, and here is where Imagemagick comes to the rescue.
First get IM and install it. You’ll find the binary release for any platform accompanied with installation instructions on the IM website.
Place all the images you wish to resize in the same directory and create a new folder called
thumbs under the same directory.
The IM tool we use is mogrify. It lets us apply various filters and operations to the images in just one step. Open terminal and go to the directory where you placed the images. What we are going to do is to resize all pictures to 80×80 pixels keeping proportions (no stretch or squash) and then extend the canvas size to exactly 80×80 pixels so that all thumbnails have the same size.
mogrify -resize 80x80 -background white -gravity center -extent 80x80 -format jpg -quality 75 -path thumbs *.jpg
-resize 80x80 is self explanatory. Note that the image is not stretched to fit the given dimensions.
-background white create a white canvas to the thumbnail. If the image does not fit completely the 80×80 space, mogrify will fill the empty space with the specified color.
-gravity center centers the thumbnail in the canvas.
-extent 80x80 extends the proportionally resized image to fit exactly 80×80 pixels.
-format jpg -quality 75 sets destination image format and quality.
-path thumbs places the thumbnails in the
thumbs subfolder. (Otherwise the original files would be replaced).
*.jpg processes all jpeg files found in folder.
This post is just to tickle your appetite, mogrify can do much more than resizing pictures, have a look at the help page on ImageMagick website and see what you have missed so far
IM literally saved my life in the past, hope it could be of some use for you as well.