Make Image Thumbnails
Use a simple script to create thumbnails from any number of images.
[Hack #2] introduced the convert utility as a means to convert between different image formats and perform basic image processing from the command line. convert also has resizing options that make it perfect for creating image thumbnails.
The primary argument used to create an image thumbnail is -thumbnail. This argument tells
convert to create a thumbnail of the input image
with the specified geometry. Thumbnails are scaled-down versions of the
original, which means the height-to-width ratio is automatically
preserved, so you need to specify only one dimension for the conversion.
For instance, to create a thumbnail that has a
width of 160 pixels, type:
$ convert -thumbnail 160image.jpg thumbnail.jpg
To create a thumbnail with a height of 160
pixels, precede the geometry with x:
$ convert -thumbnail x160image.jpg thumbnail.jpg
This command comes in particularly handy if you plan to upload a lot of digital photos to a web gallery, because you can script the entire operation. To create a thumbnail with a width of 160 pixels from every JPEG image in a directory, type
$ for i in *.jpg; do convert -thumbnail 160 $i thumb-$i; done;Each image in the directory will have a thumbnail with
thumb- at the beginning of the filename. This
command also works well to create a series of thumbnails of different
sizes—just run two different convert commands in the script. So, to create a mid-sized thumbnail with ...