Short Tutorial on using “convert” program of Imagemagick

“convert” is a program that is available with Imagemagick software. This is a frontend for performing of the image manipulations. Here are some examples.



Example parameters for “convert” program

Notes about the parameters

-interlace NONE

Do not interlace the image

-size “600x600>” -resize “600x600>”

According to the man-page, having the -size parameter helps speed up the whole resizing procedure.

-density “150x150”

Change the resolution to 150x150dpi.

myimage.TIF compressed_myimage.jpg

Name of the original image file and the name of the output file (after resizing and reducing the resolution)



Here is a simple example of resizing an image and creating a JPEG file from a TIF file. Store your scanned, uncompressed imHereage in myimage.TIF and run the following command. It will create a new file “compressed_myimage.jpg”.

convert -interlace NONE -size “600x600>” -resize “600x600>” -density “150x150” myimage.TIF compressed_myimage.jpg



Once you have the compressed image, use it to generate a thumbnail with another command like below.

convert -interlace NONE -size “120x120>” -resize “120x120>” -density “72x72” compressed_myimage.jpg thumbnail_myimage.jpg



After you have the thumbnails, you may want to add border and copyright information to the image before you publish the image on the web.

The following command adds a black border around the image. The “frame” parameter creates the look of a double matte. You can also do ornamental border if you wish. See the man-page for the convert command and experiment with it.

convert -bordercolor black -border 12x12 -frame 3x3+1+1 compressed_myimage.jpg publish_myimage.jpg



This command adds a border and writes a text at the bottom of the image. It also inserts the text “Photographer Name” into the output image file itself.

convert -bordercolor black -border 12x12 -frame 3x3+1+1 -antialias -font helvetica -fill grey -pointsize 10 -gravity “South” -draw 'text 0,2 “Photographer Name”' -comment “Photographer Name” compressed_myimage.jpg publish_myimage.jpg

Change the text “Photographer Name” to anything you wish and the border styles to your taste. If you do not like text, remove the whole “-draw” parameter. There is no harm in adding the comment to the file. A good use of the comment field is to place some sort of identification of your original image. Most of the image manipulation programs such as Photoshop erase this field after editing though and so it is not dependable.

You do not need the “compressed_myimage.jpg” any more. You only need the original file, thumbnail and the publishable compressed image (“myimage.TIF”, “thumbnail_myimage.jpg” and “publish_myimage.jpg” in this example.)

“convert” program performs a hundred other functions and you can do pretty much any form of image manipulation with it. One of the best use is to create your own signature in the form of a bitmap and you can superimpose the signature onto the compressed-image. Example later.

Automation with Convert

ImageMagick can be installed under pretty much all operating systems. If you are not familiar with programming, you will probably need some software to do these. Adobe Photoshop or your favorite image-manipulation software can create a decent gallery from a list of images with just a few clicks.

Another way to go about creating the image gallery is, to have Photoshop can do batch operations to do such things as resizing and modifying the resolution. Once you have your compressed publishable images, you can use a photo-gallery tool such as Coppermine to create a web-photo-gallery.

I installed “Cygwin” under Microsoft Windows to get a Unix-style X-windows working environment. If you choose to install “everything” under Cygwin, Imagemagick will also get installed. If you do not want Cygwin under Microsoft Windows, you probably need to install some decent command line tool such as Perl and bash to simplify your job.

Here is the script, “prep_for_web_gallery.pl.txt” that I use for creating the thumbnails and the publishable compressed images. You can download this to modify and use for your purposes. Remove the .txt extension from the filename before using it. (Disclaimer: This program is provided under absolutely no warranty and is provided as is so that you can modify for your own use. You can do anything you want with the script. Make sure you read some simple usage instructions at the top of the file and also change the copyright text that will be affixed to the images.)



Bayturtle.com, June 15, 2005