Bulk image resizing and format conversion
All of us download photos from our phones and cameras. Before we e-mail an image or post it to the Web, we may need to resize it or perhaps change the format. We can use scripts to modify these image files in bulk. This recipe describes recipes for image management.
Getting ready
The convert
command from the ImageMagick suite contains tools for manipulating images. It supports many image formats and conversion options. Most GNU/Linux distributions don't include ImageMagick by default. You need to manually install the package. For more information, point your web browser at www.imagemagick.org.
How to do it...
The convert program will convert a file from one image format to another:
$ convert INPUT_FILE OUTPUT_FILE
Here's an example of this:
$ convert file1.jpg file1.png
We can resize an image by specifying the scale percentage or the width and height of the output image. To resize an image by specifying WIDTH
or HEIGHT
, use this:
$ convert imageOrig.png ...