Linux.com

Feature

ImageMagick or GraphicsMagick?

By Nathan Willis on January 03, 2007 (8:00:00 AM)

Share    Print    Comments   

The ImageMagick (IM) suite of command-line graphics tools is a free software staple; Linux, other Unix-like operating systems, and proprietary OSes like Windows have supported IM for close to two decades. But there is also an alternative tool called GraphicsMagick (GM) that covers much of the same functionality. How do you know which one is right for you?

Though IM traces its own history back to 1987, when it was an internal tool developed at DuPont, the first public source code release was in 1990. The core package is a collection of roughly a dozen separate command-line tools: animate, compare, display, identify, mogrify, and so on.

Because its command-line interface exposes so much functionality, IM has long been employed in scripts and automated routines. It handles the server-side image manipulation duties in Web applications as diverse as personal photo galleries and Wikipedia. Over time, interfaces to many popular programming languages sprang up, opening up IM to programmers like a system library.

And in a sense, that was where the trouble began. IM is not a library -- it is a suite of discrete command-line executables. But as more and more programmers began to use IM through its language interfaces, library-like concerns crept in. Libraries have to worry about things like application binary interface (ABI) stability -- but interactive commands don't.

Several of the core IM developers who were more interested in the ABI stability question decided the answer was to make a fork of IM and start a new project that prioritized the ABI aspects and long-term stability above adding additional features. That project became GraphicsMagick, which split from ImageMagick in April 2003.

True to its word, GM has added far fewer features since its inception than IM has in the same timeframe. GM offers the same essential tools as IM -- IM has just added more options to them over the years.

To keep from overloading the commands supplied by IM, GM wraps them all into one command: gm. The names of the equivalent IM commands serve as the first argument to gm. For example, instead of running convert photograph.jpg photograph.tiff as you would with IM, you run gm convert photograph.jpg photograph.tiff.

Choices, choices ....

This decision on the GM team's part means that GM and IM can happily coexist on one system. So which do you use? The conventional wisdom is that you use IM for interactive tasks, and use GM in scripts or server-side installations. In fact, many third-party applications and frameworks that used to depend solely on IM now support GM as well -- examples include Gallery, Exhibit Engine, TYPO3, and RMagick.

But the truth is that you are highly unlikely to experience stability issues with ImageMagick in scripts or Web apps. The complaints leveled at IM during the high point of the IM-GM forking debate were that IM changed its syntax between successive releases. But how often are you going to upgrade the IM binary on a server? Not enough that the alleged ABI changes are going to bite you, particularly when you consider that 90% of IM usage is limited to pedestrian operations like resizing and scaling.

On the flip side, if you're wondering why you would ever need a command-line tool for manipulating graphics on an X-enabled PC, it's generally because the tool is the only option for some task none of the GUI image editors yet support, or as a time-saver for batch operations on very large files (particularly high-bit-depth images). I used to send digital images to a professional photo printer who demanded very specific settings for color space and embedded profiles, and in some cases converting the outgoing files to spec with IM was my only option in Linux. As great as the GIMP, Krita, and CinePaint are, support for new features and formats often makes it into IM first.

If you are developing an application or tool, take some time to pore over the language bindings for IM and for GM; availability of the right bindings on one but not the other would make the choice obvious. But unless you absolutely without-a-doubt need some new IM option not yet available in GM, the safe bet is to stick to GM's feature set, and write your app to work with either one.

In the past year, the development branch of GM has started adding more features, and new contributors to IM have focused their energy on stabilizing the suite's sometimes convoluted syntax, so the gulf between the packages may be narrowing. From a community standpoint, it is a shame to witness a less-than-amicable project fork, even when the technical reasons are real. I am not suggesting that we will someday see the IM and GM projects merge, but it is good to see that they can cross-pollinate and continue to learn from each other.

Share    Print    Comments   

Comments

on ImageMagick or GraphicsMagick?

Note: Comments are owned by the poster. We are not responsible for their content.

Why switch?

Posted by: Anonymous Coward on January 04, 2007 01:54 PM
instead of running convert photograph.jpg photograph.tiff as you would with IM, you run gm convert photograph.jpg photograph.tiff.

ImageMagick would appear to be more efficient for the end user as there are three less keys to press to convert a file. So why switch?

#

Re:Why switch?

Posted by: Anonymous Coward on January 11, 2007 05:09 AM
We've tried both IM and GM but have not found anything that that GM does that IM cannot and IM seems to have more features as evidenced in these web pages: <a href="http://www.cit.gu.edu.au/~anthony/graphics/imagick6" title="gu.edu.au">http://www.cit.gu.edu.au/~anthony/graphics/imagic<nobr>k<wbr></nobr> 6</a gu.edu.au>.

#

Image Magic is the best choice.

Posted by: Anonymous Coward on January 05, 2007 01:51 AM
In fact, many third-party applications and frameworks that used to depend solely on IM now support GM as well -- examples include Gallery, Exhibit Engine, TYPO3, and RMagick.

Conversely many applications rely on ImageMagic and do NOT support GM. One noteable package requiring ImageMagic is libxine, part of the Xine video play package. Dependencies such as this mean that ImageMagic will offer the best compatibility, as well as the stability that you mentioned. Furthermore, since GM offers little or no additional functionality over ImageMagic, it is pointless to write your scripts with the GM syntax and it is redundant to have them both on your system.

ImageMagic is definitely the best choice, I think the GM people lost their way the moment that the decided to wrap the commands. As you stated one of their issues with ImageMagic was a change in the ImageMagic syntax to which they responded with a further change in the syntax by wrapping it with GM. ?????

#

why I moved from IM to GM ...

Posted by: Anonymous Coward on January 05, 2007 11:24 AM
A couple of years ago I was doing a fair bit of image resizing and padding (desktop wallpaper). Experimentation revealed that IM had a host of annoying off-by-one-ish bugs. For example, I couldn't ask for an image to be padded by zero pixels (on one axis - non-zero on the other, thus the need for padding); I needed to bogusly pad by at least one pixel and then crop it away again. GM had all that stuff fixed.


Also, I have long been offended by IM's rather gratuitous pollution of the command space with "convert", "display" and suchlike very generic names. The "gm" command is the Right Thing to do.

#

IM is a great idea, but a poor implementation.

Posted by: Anonymous Coward on January 06, 2007 02:20 AM
They STILL have major bugs that have been there for years. Try the "mogrify" command with any of the following DOCUMENTED options and you still get "unknown option". -posterize -sigmodial-contrast -tile -tint -transform

I've not tried GM, but I think I may do so now if it supports the functions I need properly.

#

Re:IM is a great idea, but a poor implementation.

Posted by: Anonymous Coward on January 11, 2007 08:44 AM
The -posterize, -tile, etc., options you mentioned seem to work fine with the latest ImageMagick release.

#

Re:Try NetPBM suite before you choose

Posted by: Anonymous Coward on January 07, 2007 07:00 AM
+10. I'd say the same. I haven't used GM - but tried IM. And I found it to be pretty buggy and poorly documented.

NetPBM though primitive, does its job.

On several occasions I have tried to compile IM by myself and after many wasted hours just given up on that stinking pile of [self-censored]. Thankfully, I was hinted to try NetPBM and soon discovered that it could do nearly 100% of what I ever needed. (*) It doesn't pretend to be complete, integrated, all-in-one or anything - it just allows me to do the job. And it is well documented and ported to uncounted number of platforms.

I sincerely hope something have changed in IM land in last five years I haven't used it. (Recalling size of code base I'm not holding my breath - it is easier to reimplement it from scratch). But it's just hard to beat the overwhelming simplicity and convenience provided by netpbm.

(*) netpbm is missing font rendering I though would be required. But as later turned out, UI designers of application were strongly against giving programmers control over how the output rendered. IOW, the only unique for application feature of ImageMagik - font rendering - was not needed. And using netpbm with bitmaps prerendered by designers I could compose any image required right on runtime.

#

Re:GM is way faster!

Posted by: Anonymous Coward on January 13, 2007 12:37 PM
<a href="http://www.baschny.de/graphic-test" title="baschny.de">http://www.baschny.de/graphic-test</a baschny.de> shows IM/GM/Netpbm/GD benchmarks. The benchmarks suggest very little difference in time between IM/GM, at least for resizing images.

#

Re:GM is way faster!

Posted by: Anonymous Coward on January 14, 2007 10:44 AM
"Last updated on 14-Sep-2004"

Kinda outdated. If you're into batch processing a huge amount of image files you should make some tests before chosing your preffered "Magick". It's been about 24h now since I changed from IM to GM. =)

#

IM-broken support for file formats GM- 100% fit

Posted by: Administrator on January 24, 2007 09:34 AM
I dont know how many features did IM added in last 3 years but I know one thing that one of the primary idea behind these kinds of tools is support (solid) for different file formats. There is one file format that i work with most of the time "DPX" that is well supported in IM but it fails to open almost 80% of them. And GM just works perfectly because they have a complete implementation. where IM would only read a basic RGB DPX planar file, GM would read Planar, Interlaced, RGB or YUV or CineonRGB, 8 bit or 16 bit (Quantum) and all the other DPX files that i have ever came across. So no wonder IM has added so many partially implemented features and GM has not.

#

Try NetPBM suite before you choose

Posted by: Administrator on January 04, 2007 02:10 PM
The older and extensively featureful NetPBM suite is an excellent alternative which has given me more efficient results than the ImageMagick suite ever could. I first encountered it in its original PBMPlus form and the community has taken it over with the NetPBM project.

If you can get over the fact that with NetPBM you need to convert to an intermediate format you might find it far exceeds what ImageMagick can do, and does it faster and more accurately (like resampling, text superimposes, palette normalization).

#

GM is way faster!

Posted by: Administrator on January 12, 2007 01:57 PM
"Since GraphicsMagick is more “stable”, more time has been spent optimizing and debugging its code. GraphicsMagick is often faster than ImageMagick."

  -- GraphicsMagick's FAQ, Question #1



True. GM runs in about 70% of IM's time. It's a huge difference for batch processing.



shalbum now supports both GM and IM and defaults to GM. [1]



[1] <a href="http://sf.net/projects/shalbum" title="sf.net">http://sf.net/projects/shalbum</a sf.net>

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya