How to Enable / Install Imagemagick on Drupal 6

Author:
phil
Created:
Thursday, October 15th, 2009
Last Updated:
Saturday, May 07th, 2011

Disclaimer: Accessing the information on this page means you agree to the Sites Terms of Service


The Background

Imagemagick is typically the preferred image rendering software of choice for a lot of folks who need the server to manipulate images on a server. For Drupal, it is unfortunately not an option by default, (GD2 is...) and must be manually added in. The "howto enable imagemagick" Drupal handbook only partially covers the process on how to enable or install imagemagick on Drupal 6, so I would like to cover a more intuitive documentation on doing so. If you are unsure on which to use, here is a little more information on the differences between Imagemagick vs. GD2. (In a nutshell, GD2 uses PHP to process image manipulation whereas ImageMagick uses an installed binary on the server to process images which basically removes an extra layer of using PHP which will cause more server load...)

If you are using the brand new and shiny Drupal 7, there is a dedicated imagemagick module! Simply install, enable and configure! (For Drupal 6, keep reading...)

The Need

Some folks use the Image module, others use CCK Imagefield. I personally like CCK Imagefield for is versatility and in-node use, however it is the Image module, that contains the necessary goods to enable Imagemagick for Drupal 6. This is basically a tutorial for the folks who use CCK Imagefield but don't want the full clutter of the Image module.

The Installtion

(assuming you don't use the image module, only CCK imagefield)

1) Download the latest version of the Image module

2) Extract the Image module somewhere on your computer

3) Copy the image.imagemagick.inc file to your [Drupal root]/includes folder.

4) Dig into the following folder: image/contrib then copy the image_im_advanced folder over to your /sites/all/modules folder

5) Enable the "ImageMagick Advanced Options" module from your modules config page (http://yoursite.com/admin/build/modules)

6) Once the "ImageMagick Advanced Options" module is enabled, go to your Site Configuration -> Image Toolkit page and enable ImageMagick

7) Feel free to delete the "/sites/all/modules/image" folder at this point since everything else won't be used.

That's pretty much it!
If you get to the Image Toolkit page and you don't see the option for ImageMagick, only GD2, double check that you copied the image.imagemagick.inc file to your core Drupal "includes" folder.

This will start processing images through ImageMagick instead of GD2!

One more thing that might help is to create a php.ini file in the root of your Drupal install folder and add the following line:

memory_limit = 40M

The "40M" basically reserves 40MB of memory for PHP to use while processing... well, anything... I don't know what the lower end can really be, but the Filefield module tends to throw up errors if the memory limit is too low. If you are on a hosting service, consult them on what the maximum limit is that you can set your own memory level to. On HostGator, it is allowed to a Maximum of 64M (but can be changed to a lower amount...)

Post Comment

Comments

You can use the ImageAPI module and turn on ImageCache Support with that module so might look into that instead of getting stuff out of the image module

It's been a while since I needed to set all of this up, and maybe the ImageAPI has the Imagemagick working properly on certain server configurations, but on the server I use, the only way to get an image bigger than a couple of megs uploaded through FileField, was to do the method I described (It's the only workaround I could find at the time) Even back when I posted this, ImageAPI had the ability to convert images using Imagemagick, but FileField would always crap out regardless of the ImageAPI being set to Imagemagick. I know there was a bug with FileField back in the day too and that might be what is actually working as opposed to ImageAPI... I honestly don't know at this point.

I do want to say thx for the info on ImageAPI "working" and when I get an opportunity to sit down and test it, I'll post an update.