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).

14 comments:

  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!"

    ReplyDelete
  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%.

    ReplyDelete
  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.

    Regards,
    Tuk

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

    ReplyDelete
  5. Thanks for the comments! Documentation is available at www.php.net/gmagick. 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 php.net and elsewhere. Will post links on this blog.

    ReplyDelete
  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?

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

    ReplyDelete
  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.

    Regards
    John

    ReplyDelete
  9. Check out the article on the October 2009 issue of php|architect (http://www.phparch.com/). There's also an article on DevZone (http://devzone.zend.com/article/10531).

    ReplyDelete
  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?

    ReplyDelete
  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 http://www.graphicsmagick.org/FAQ.html#how-does-graphicsmagick-differ-from-imagemagick.

    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 http://www.kitchensoap.com/2009/04/03/slides-from-web20-expo-2009-and-somethin-else-interestin/.

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

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

    ReplyDelete