Ars Informatica
August 12, 2020
Health Care Informatics
Web-based MySQL/PHP Databasing
Web Development
Favourite Software
Hardware for the Frugal Fanatic
Graphic Design and Image Processing
Free Scripts and Software
About Us
Contact Us

 Article Feed for this site

Image creation, conversion and manipulation with ImageMagick

March 26, 2006

ImageMagick logoImageMagick consists of a set of powerful, open-source (free!) routines used to create and edit bitmap images. These can be called directly by web pages, i.e. through the PHP exec() command, by batch programs, or any software you've written. Or incorporate the Magick via the appropriate interface for your platform, i.e. PerlMagick, Magick++ (C++), PythonMagick, MagickWand for PHP, RMagick (Ruby), TclMagick (Tcl/Tk), L_Magick, JMagick (Java), and others. It's available for all major operating systems.

ImageMagick reads, converts and writes images in over 90 formats, including GIF, JPEG, JPEG-2000, PNG, PDF, PhotoCD, TIFF, and DPX. Crop, resize, stretch, or rotate; sharpen, reduce the number of colors in the palette, make the image transparent, or sepia-tone it. Merge images, or combine them into an animated GIF. Add text, lines, polygons, ellipses and Bézier curves.

One example - crop an X-ray to the area of interest, create a negative image, resize to maximum height and width of 200 pixels, and save as a JPEG at almost-lossless quality:

convert -crop 570x740 -negate -resize 200x200 -quality 90 knee.jpg knee1.jpg

X-ray knee, negative imageX-ray knee

Another example - convert a full-color image to a charcoal sketch:

convert -charcoal 1 cokecan.jpg cokecan1.jpg

can of CokeCoke can, charcoal sketch

ImageMagick is distributed under the GPL model. Full source code is included, and may be freely modified and distributed.

Of course, nothing is perfect. The number of options are overwhelming, so much so that it's almost impossible to visualize the enormous range of possibilities these routines offer. Complex commands take a long time to craft. And my web hosting service no longer permits the PHP exec() command to be executed - this command opens the door for crackers: if they can upload one .php file, they can destroy your system.

Finally, because my web host hasn't installed MagickWand for PHP, I'm stuck using PHP's gd graphics library - see the related Image creation and manipulation using the gd Graphics Library.

Copyright © 2020 Ars Informatica. All Rights Reserved.