PDA

View Full Version : Perl Image::Magick module causing error


mlseim
07-26-2006, 01:51 AM
This is sort of unique to a particular webhost, but I'll ask anyhow.

Cleverdot.com says they have the module installed and it shows up
on cpanel. "Image::Magick"

When I try to run the script below, it fails.

Does anyone have experience with using cleverdot.com, or might know
why I might be having a problem. Of course, their tech support tells me
to use their built-in photo gallery, but I want to use my own image resize
with Perl.

I tried out my test script on "ipowerweb.com" and it works just fine.

As in my example below ... just the minimum to test it out.
Read an image, save it ... nothing else.

If I comment out: use Image::Magick the script prints "test",
otherwise, it fails "encounter server error ... etc".

#!/usr/bin/perl

use CGI qw/:standard/;
use Image::Magick;

print"Content-type: text/html\n\n";

print "test";

my($image, $x);
$image = Image::Magick->new;
$x = $image->Read('../../uploads/test.jpg');
warn "$x" if "$x";

$x = $image->Write('../../uploads/test.jpg');
warn "$x" if "$x";

FishMonger
07-26-2006, 03:18 AM
I don't have any experience with Cleverdot.com or the Image::Magick module, but lets see if we can narrow down the problem.

Have you verified that it can load the module without error? Do you have shell access to the server? If so, this simple command will tell if the module is installed and accessable to Perl.

perl -MImage::Magick -e 1

You can also redirect the fatal errors to the bowser to get a better idea of the problem.

use CGI::Carp qw(fatalsToBrowser);
use Image::Magick;

If the module loads without error but dies when executing the $image->Read or $image->Write portion of the script, then the module may need to be reinstalled.

FishMonger
07-26-2006, 03:28 AM
Since you're using warn which sends its output to STDERR, you won't see any error message from the $image->Read or $image->Wite because output to the browser is via STDOUT. You need to use the CGI::Carp module to redirect STDERR to STDOUT.

mlseim
07-26-2006, 02:04 PM
FishMonger ... thanks for the ideas.

I finally got a tech to look into my problem.
They fixed it, but have not yet told me what they did.

I'm guessing they re-installed something, or found a path problem
on their server. This leads me to believe that not many of their
customers are using Image::Magick? I'm guessing most are using
PHP with GD (which has really sucky resizing capabilities). GD does
good with "resampling" instead of "resizing", but it takes 10 times longer
to resize an image.

I've found ImageMagick to do a terrific resize job quickly and efficiently.

When they tell me what they did, I'll let you know ... as information for the
next guy that has this problem. Thanks again