Tuesday, January 13, 2009

Allow MediaWiki To Use ImageMagick 5.x

I was hoping to use ImageMagick with MediaWiki for image uploads and resizing. Unfortunately, I only had ImageMagick version 5.x installed. With this version, MediaWiki produces and error since it is trying to send the -thumbnail option to ImageMagick's convert function.

In version 5.x of ImageMagick, -resize does basically the same thing (-thumbnail just strips the metadata from the image). So, instead of upgrading to version 6.x of ImageMagick, a quicker solution was to add the following to my LocalSettings.php file:

$wgCustomConvertCommand = "/usr/sfw/bin/convert -resize %wx%h %s %d"

This line is documented in DefaultSettings.php and is meant for using another graphics library like GM. But instead, I just added in the convert command for ImageMagick 5.x. Note that this line would be added to LocalSettings.php in place of the $wgUseImageMagick and $wgImageMagickConvertCommand variables.

No comments: