Page 1 of 1

PerlMagick + Apache 2.2.4

Posted: 2007-07-11T23:54:12-07:00
by shay
Hi,
I'm using ImageMagick for years now and I just love it.
A few days ago, I installed a new server (running Fedora Core 6 Linux OS) using the built in packages - Apache 2.2.4, mod_perl 2.03 and ImageMagick 6.2.8
It's the 4th day now which I'm fighting with this thing, the problem is that:
When running PerlMagick through apache and trying to create a file and save it (using $image->write), it seems like no file is being created and no error is being logged in Apache error log.
Using PerlMagick own debugging features I have managed to get a 410 error which tells me nothing.

When running the same script using command line everything is working just fine.
I've already done the followings:
1. Verified the permissions on the target path and gave apache the correct rights.
2. Ran a test using the same script with open (FILE,">/same_path/same_file_name")... this test did create the file.
3. I tried several versions of ImageMagick and PerlMagick, installed them from source, also tried 6.3.5 and they all acted the same.

Any ideas whats going on here ? :shock:

Re: PerlMagick + Apache 2.2.4

Posted: 2007-07-12T00:50:39-07:00
by anthony
The web runs in a different environment as a different user. It may not be able to read or write some files, especially if you also have SELinux protection enabled (the default). Check the syslogs and the httpd error log files carefully. Add debugging and trace code to your programs output. etc etc etc.

If it does run from command line, then IM itself is fine, and it is an environment problem.

Re: PerlMagick + Apache 2.2.4

Posted: 2007-07-12T07:14:07-07:00
by shay
Thanks for answering.
SElinux is disabled on my system, syslog shows nothing and apache error log produces "Exception 410: no images defined `Image::Magick'"
The same script is running great when running from command line using apache account.
It is also running great on my other machines which run apache 2.0.xxx and earlier version of ImageMagick.
Do you have any other idea ? what "Exception 410: no images defined `Image::Magick'" means ? :shock:

Re: PerlMagick + Apache 2.2.4

Posted: 2007-07-12T08:49:33-07:00
by magick
The exception means you are trying to perform an operation (.e.g resize) on an Image::Magick object that does not contain any images to operate on. Most likely you have a read operation that fails but you do not properly check for the exception, for example:
  • $x = $image->Read('image.jpg');
    warn "$x" if "$x";

Re: PerlMagick + Apache 2.2.4

Posted: 2007-07-12T21:26:46-07:00
by anthony
It also could mean the image you are reading is corrupt.

Re: PerlMagick + Apache 2.2.4

Posted: 2011-03-09T14:38:14-07:00
by nhcoding
I also ran into this same problem on CentOS v5.5. The problem in a nutshell:
+ run script from command line as apache and it works without error
+ run same script via apache server using mod_perl and it errors

I tracked the problem down to the following line of my code:
$img->ReadImage('xc:rgb(0,0,0)');

After adding code to check the return status, I discovered that when run via mod_perl I would get an error "unable to open file xc:rgb(0,0,0)". WTF I say to myself, it shouldn't be trying to open a file.

I upgraded from ImageMagick v6.2.8 (CentOS supported version) to v6.6.5.10-1 (REMI Repository), restarted Apache and now my code is working.