Recently I had got strange request from our web designing developers they want me to create thumbnails for all images (around 10000+ images). First I thought it will be easy, I went through software such as Gimp and then searched online etc.
Finally friend of mine who is a graphics artist and uses Linux actively pointed out me wonderful utility called create which is part of ImageMagick Studio software. ImageMagick is a free software suite to create, edit, and compose images. It can read, convert and write images in a large variety of formats. Images can be cropped, colors can be changed, various effects can be applied, images can be rotated and combined, and text, lines, polygons, ellipses and Bezier curves can be added to images and stretched and rotated. And guess what, it can be use from shell prompt and you can write shell/perl scripts too.
Install imagemagick, use apt-get command as follows:
# apt-get install imagemagick
You need to pass -thumbnail argument to convert command:
convert thumbnail <width>x<height> image.png thumbnail.png
So to create a thumbnail of the abc.png image with 200px width, you need to type:
$ convert -thumbnail 200 abc.png thumb.abc.png
To create a thumbnail of the abc.png image with 200px height, you need to type:
$ convert -thumbnail x200 abc.png thumb.abc.png
But, hold on real part is ahead, since I had to go through 10000+ images I wrote perl script (although I can not put real script here because of legal issues). Nevertheless here is sample shell script:
#!/bin/bash FILES="$@" for i in $FILES do echo "Prcoessing image $i ..." /usr/bin/convert -thumbnail 200 $i thumb.$i done
Update: Tim (below in comment) pointed out another method and script, to create thumbnails for jpg images with optimization in mind.For more information see:
- ImageMagick Studio software website.
- convert man page