UPDATE 2016-11-07: This is an old post. PHP’s “gd” library has come a long way and it’s hardly necessary to switch to ImageMagick at all. In fact I wouldn’t recommend it at this point. Please keep that in mind if you read the rest of this article.

The OnePica_ImageCdn extension enables you to host the category and product image cache on a CDN or a separate server. It’s a great extension that worked out of the box when I tried it with Amazon S3. But our client was using ImageMagick for image manipulation instead of GD2. And OnePica_ImageCdn only supports GD2 at the time of this writing.

So I quickly put together a module that added ImageMagick support to ImageCdn. Here’s a quick overview of the steps:

  1. Create a new Magento module that depends on OnePica_ImageCdn (you don’t want to modify the extension’s files directly!)
  2. Create an overwrite for “imagecdn/varien_image”. The new model will call a new ImageMagick adapter which we will add below.
  3. Add the ImageMagick adapter (you can get the code online and adapt it or use the one in my Gist – see below).
  4. Make sure your adapter’s save() method calls Mage::helper(‘imagecdn’)->factory()->save(). See the customisations OnePica applied to the GD2 adapter (OnePica_ImageCdn_Model_Varien_Gd2) for an example of what you should do in your ImageMagick adapter.
  5. Enable your module and test.

If all you want is the code… well here’s a Gist of the most important files – enjoy putting the module together!

If this small article or the code was useful for you, please make sure you leave a comment!

2 Comments ImageMagick Support for OnePica_ImageCDN Magento Extension

  1. Baby in magento

    Hi,

    Thanks for nice post, i need to integrate an imagemagick in one magento 1.9 site. please help me how i can intergate imagemagick

    Thanks

    Reply
    1. Gabriel Somoza

      This is an old post. Nowadays, PHP’s “gd” library – especially on PHP 7 – should be fast enough to somewhat match the performance of ImageMagick. So I would recommend not switching to ImageMagick.

      Reply

Leave a Reply