ImageMagick: Introduction (identify, convert, montage)


ImageMagick is a suite of tools to treat bitmap images.

www.imagemagick.org


How to install ImageMagic in Debian


$ sudo aptitude install imagemagick


Examples


Examples of ImageMagick usage:
http://www.imagemagick.org/Usage/


Show information about an image file

$ identify my_image.jpg
my_image.jpg JPEG 4608x3456 4608x3456+0+0 8-bit sRGB 3.53MB 0.000u 0:00.000


Convert from one image format into another

ImageMagick supports more than 200 image formats.

From convert man page we find how to call convert command:
convert [input-option] input-file [output-option] output-file


To convert a PNG file into a JPG one:
$ convert cursor_up.png cursor_up.jpg


Resize an image.

E.g: double size of the image
$ convert cursor_up.png -resize 200% cursor_up_big.png

or by half:
$ convert cursor_up.png -resize 50% cursor_up_small.png


Decrease opacity by half in a png image:

$ convert cursor_up.png -alpha set -channel A -evaluate Divide 2 cursor_up_transparent.png

http://stackoverflow.com/questions/13366273/creating-a-semi-transparent-png-with-imagemagick-on-centos-linux


Create a composite image combining several separate images

$ montage '*.jpg[200x200]' -geometry 200x200+5+0 -frame 2 index.jpg

It gets every jpg image, resizes it to 200x200.
Then it joins them in 200x200 squares separated horizontally by 5 pixel offset.
It Uses second ornamental frame.
At last it names the output picture: index.jpg


Crop an image

We cut part of an image

http://www.imagemagick.org/Usage/crop/

We have an original image we want to crop: orig.jpg
$identify orig.jpg
orig.jpg JPEG 700x525 700x525+0+0 8-bit sRGB 75.6KB 0.000u 0:00.000


Crop option does not change image scale, just cuts out part of the image.
$ convert orig.jpg -crop 400x525+100+0 test01.jpg

It cuts out a 400x525 part using 100 as horizontal, and 0 as vertical offsets.

$ identify test01.jpg
test01.jpg[1] JPEG 400x525 400x525+0+0 8-bit sRGB 41.2KB 0.000u 0:00.000


$ convert orig.jpg -crop 400x525+100+100 test02.jpg
$ identify test02.jpg
test02.jpg[2] JPEG 400x425 400x425+0+0 8-bit sRGB 37.9KB 0.000u 0:00.009
New image size is less than 525 because we offset the image vertically by 100 pixels.


Reference


$ man convert
$ man montage

http://www.imagemagick.org/script/convert.php