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:
- Create a new Magento module that depends on OnePica_ImageCdn (you don’t want to modify the extension’s files directly!)
- Create an overwrite for “imagecdn/varien_image”. The new model will call a new ImageMagick adapter which we will add below.
- Add the ImageMagick adapter (you can get the code online and adapt it or use the one in my Gist – see below).
- 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.
- 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!