Converting Images using ImageMagick – convert

October 21, 2011

Offlate I am uploading lot of images to my blog.  Normal images from digital camera contain lot of information like camera details, flash status etc. While putting on web I would like to reduce the size of the file so that it is easy for uploading as well as for viewing. I found convert tool of Image Magick very useful.

convert offers various options like strip, resize etc. The syntax is

convert -options input_image_file  output_image_file

Here is an example


$ convert -strip img_5735.jpg new_img_5735.jpg
$ ls -l
 total 2308
 -rwxr-xr-x 1 ram ram 1252058 2011-10-21 07:30 img_5735.jpg
 -rw-r--r-- 1 ram ram 1098785 2011-10-21 07:31 new_img_5735.jpg

From the above you can see merely stripping the info about the images saves considerable space. If you want to reduce image size  you can use resize option like this

convert -resize 50% img_5735.jpg  reduced_image.jpg

For converting many images I use this simple shell script

for file in `ls *JPG`

do

convert -strip -resize 50% $file new_$file

done

convert has several other options, see man convert.

To use convert you should install ImageMagick Package