Issues with ImageMagick/Mod_perl/Html::mason

Today, i was working with a web-based mod_perl application running on an old rhel 2.1 (panama) server, with apache v1.3.33 and mod_perl v1.29.

The applctn had an option to upload images for the products displayed on the site. But the app lacked image resizing functionality. Some of the users had uploaded huge images and that went beyond the site borders. I was about to integrate the resizing function using perl’s Image::Magick module. Existing module was out-dated, so i went for an upgrade. Obviously, it was not a quick and easy upgrade.

For the code snip

[perl]
$image = Image::Magick->new;
$x = $image->Read($imgname);
if($x eq ”)
{
$image->Resize( geometry => ‘800×800’ );
$image->Write($imgname);
}
[/perl]

The first error i met was

Can’t load ‘/usr/lib/perl5/site_perl/5.6.1/i386-linux/auto/Image/Magick/Magick.so’

i ran ldd command on Magick.so, and libMagick.so link was found broken

[bash]
ldd /usr/lib/perl5/site_perl/5.6.1/i386-linux/auto/Image/Magick/Magick.so
libMagick.so.6 => not found
[/bash]

So downloaded ImageMagick-6.2.3-6.tar.gz and reinstalled ImageMagick.

For a successful compile, i had to comment the following lines in /usr/src/ImageMagick-6.2.3/magick/annotate.c

[perl]
//      if (LocaleCompare(encoding,"Latin-1") == 0)
//        encoding_type=ft_encoding_latin_1;
[/perl]

because ( i guess ) the machine lacked that font.
After that, the app threw another error
Wrong JPEG library version: library is 62, caller expects 70

This was fixed by relinking libjpeg.so.62 to libjpeg.so.7.0.0. I know its dirty, but that did the trick.

Hope, mod_perl/mason players will find this useful.

Leave a Reply

Your email address will not be published. Required fields are marked *