Sunday, May 17, 2009

The Gmagick Extension

I am excited to announce the release of the Gmagick PHP extension, which I ported from Imagick along with Mikko Koppanen, one of the Imagick author who got me to do the extension and guided me along the way.

The extension seeks to make the image processing capability of GraphicsMagick accessible from PHP. GraphicsMagick is forked from version 5.5.2 of ImageMagick and had since developed with important differences and improvements (for more details, see GraphicsMagick's website).

In terms of Gmagick and Imagick, we try to keep the method interface similar so existing Imagick users will find converting to Gmagick a breeze. One major difference however, is that most of the mutator methods in Gmagick are chainable.

We'll leave you to decide which extension is more suitable for your needs. A high level difference that we keep in mind when developing Gmagick is that Imagick's feature set is more extensive and powerful, whereas Gmagick should be simpler and more efficient (see benchmarks).


  1. Does it have compatibility with PHP 5.3-dev? I'm going to find out in about an hour, but it would be nice if it did.

    All I have to say is, "Yes!" and "Oh hell yes!"

  2. Seems nice.. but I have a hard enough time finding documentation on how to use the imagick php extension.. this one seems to lack that as well..

    Documentation for the supporting library isn't enough..the mappings don't always match 100%.

  3. Hi Vito,

    Gmagick looks promising!

    But can you point me to api documentation/example code? I can't find anything besides the source code itself.


  4. Awesome. I'm sick of GD2's inefficiency and tried GM today, which is just so much faster.
    Great work!

  5. Thanks for the comments! Documentation is available at Several people had gone through the Gmagick API docs, but if you find anything or wish to share examples, feel free to contact me. There will also be more examples and guides upcoming on and elsewhere. Will post links on this blog.

  6. I've been migrating a PHP app from magickwand to gmagick ... everything was going well until I tried to find a suitable replacement for MagickGetStringWidth().

    I don't see any sign of this or QueryFontMetrics anywhere in the gmagick extension. Any idea if this will be added soon?

  7. The queryFontMetrics() method is available on Gmagick v1.0.3b2.

  8. Any chance of a getting started guide, some very simple examples, etc. All I want to do is take an image and create 4 standard sized, padded square 'thumbnails', but I have no idea where to start.


  9. Check out the article on the October 2009 issue of php|architect ( There's also an article on DevZone (

  10. ImageMagick is a great tool, but not without it's problems. I've seen it consume tons of memory, and write huge files to disk for no apparent reason. I've also found MagickWand to be a buggy interface, where parameters like image quality just don't as advertised, or expected.

    Does GMagick address some of these issues?

  11. Gmagick is a PHP extension that exposes GraphicsMagick functions. GraphicsMagick was forked from ImageMagick in 2002. While ImageMagick focuses on adding new features, GraphicsMagick has maintained a stable interface; more time had been spent optimizing and debugging its code. See

    Accordingly, GraphicsMagick is more efficient with large images as well but I had not done any memory consumption profiling or benchmarking of GraphicsMagick myself. Speed-wise, the Flickr guys observed that GraphicsMagick is about 15% faster (with version 1.1.5!), see

  12. Am I just daffy or is there no way to set JPG compression levels before writing?

  13. Yes, there is, it's setCompressionQuality(int).