Image types that convert supports include .jpg, .bmp, .gif, .png, .tiff, .xpm,
.xwd, and .pcx
Resizing images:
$ convert -resize 800x400 kitty.jpg kitty-sm.jpg
$ convert -sample 50%x50% dog.jpg dog-half.jpg
The first example creates an image (kitty-sm.jpg) that is 800 × 400 pixels. The second example reduced the image dog.jpg in half (50%x50%) and then saves it as dog-half.jpg.
Creating thumbnails:
$ convert -thumbnail 120x120 a.jpg a-a.png
$ convert -thumbnail 120x120 -border 8 a.jpg a-b.png
$ convert -thumbnail 120x120 -border 8 -rotate 8 a.jpg a-c.png
Where the convert commands can really shine are when you use them in scripts. Instead of resizing, rotating a single file, you can do any or all ofthose things to a whole directory of files.
Here's an example of a script you can run to resize an entire directory of photos to
800 × 400 pixels to upload to flickr or something:
$ cd $HOME/images $ mkdir small $ for pic in `ls *.png` do echo "converting $pic" convert -resize 800x400 $pic small/sm-$pic done
No comments:
Post a Comment