Click to See Complete Forum and Search --> : ImageMagick easy fix?


KitsuneRamen
08-02-2007, 08:53 AM
So, I've done some extensive developing with my professor at my college, and he has been teaching me perl and all that mysql/database fun. I'm still really new, and its sometimes REALLY hard to troubleshoot things. After designing and building two websites with him on his server (which is very pretty sitting in its rack amongst the other bazillion that the school has) I thought I would be ready to work on my own. Of course I don't own my own server, so I'm paying yahoo for space (http://smallbusiness.yahoo.com), so he helped me set up a database there and helped me work on my perl on his server before uploading onto yahoo. (and it worked fine on his server) Unfortunately after coping all the necessary files and database information, it just didn't work. We got a lovely error message:

500 Internal Server Error

The server has encountered an internal error or misconfiguration and was unable to complete your request.

Yes, because that tells me jack squat. Anyways, I've been doing little test runs with bits and pieces of my coding and I think what is causing the problem is ImageMagick. I'm currently defining(?) it at the top of my perl:

#!/usr/bin/perl -w
#use strict;
use Image::Magick;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use DBI;
my $q = new CGI;
my $time;
my $pname;
my $name=$q->param('name');
my $type=$q->param('type');
my $page=$q->param('page');
etc...

I tried doing this to test it (which worked just fine):
#!/usr/bin/perl -w
print "Content-type: text/html\n\n";
print "<html><head><title>Perl</title></head>\n<body>\n";
print "testingtesting";
print "</body></html>";

and then added in the ImageMagick:
#!/usr/bin/perl -w
use Image::Magick;
print "Content-type: text/html\n\n";
print "<html><head><title>Perl</title></head>\n<body>\n";
print "testingtesting";
print "</body></html>";
and I get nada! I get the "website cannot display the page" error... which like I said means jack squat to me. Am I simply doing something terribly wrong? I feel like there is an easy fix.

PS: The first of the two websites I did is here: http://bio2.elmira.edu/WISE and the second I can't give out yet, since it hasn't been approved by the college quite yet.

KitsuneRamen
08-02-2007, 08:54 AM
Oh and while I'm thinking about it, I did do some digging around on yahoo, and they DO SUPPORT IMAGEMAGICK!

dragle
08-02-2007, 10:18 AM
You might try:

#!/usr/bin/perl -w

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

print "Content-type: text/html\n\n";
print "<html><head><title>Perl</title></head>\n<body>\n";
print "testingtesting";
print "</body></html>";

This assumes that they have CGI::Carp on their server, but chances are good that they do. And be sure to put the CGI::Carp load BEFORE the ImageMagick load.

When you run that, you should see the literal error message that's crashing the script displayed in the browser. If that doesn't work, then you might try this one, instead:

#!/usr/bin/perl -w

use strict;

print "Content-type: text/html\n\n";
print "<html><head><title>Perl</title></head>\n<body>\n";

eval "use Image::Magick";
print "ERROR: $@" if ($@);

print "</body></html>";

But it sounds to me like your first instinct is probably correct; the module is most likely not being found on the Yahoo! server.

Good luck!

KitsuneRamen
08-02-2007, 12:49 PM
So, I tried moving the Magick line down under the CGI line like you said and I think I finally got a valuable error message. But an error message nonetheless. Its as follows:
Can't load '/usr/lib/perl5/site_perl/5.8.7/i386-freebsd/Magick.so' for module Image::Magick: Too late to replace libc with libc_r
at /index.pl line 5
Compilation failed in require at /index.pl line 5.
BEGIN failed--compilation aborted at /index.pl line 5.

and when I tried your last bit of code, I got a similar error:
ERROR: Can't load '/usr/lib/perl5/site_perl/5.8.7/i386-freebsd/Magick.so' for module Image::Magick: Too late to replace libc with libc_r at (eval 1) line 2 Compilation failed in require at (eval 1) line 2. BEGIN failed--compilation aborted at (eval 1) line 2.

So.... I figured hey, I'll just take that line out completely and find some other ingenious way of altering incoming images. humm... so, I cut it out and decided to run the perl... and guess what... both IE and Firefox both prompted me to download it or find a program that can run it... rather than just running it... its the weirdest thing...

dragle
08-02-2007, 01:39 PM
I'm not an Image::Magick guru myself; but I would guess that the Perl Module installed on the server is not in sync with the actual ImageMagick libraries (one was updated separately from the other); so the "Too late to replace..." error is probably an issue for your server support folks. You might also try poking around on the ImageMagick site itself if you haven't already: http://www.imagemagick.org/script/perl-magick.php for clues.

For the delivering-perl-code-as-a-download problem, double check a couple things:

1.) Make sure the perl code is in an executable area of your server; i.e., usually only the cgi-bin. You may or may not also have to ensure that the script has a .pl extension (some servers allow executing the scripts outside the cgi-bin, but ONLY if they have the .pl extension).

2.) You may need to set the execute rights on the perl script for the server to execute it as such; i.e., something like

chmod a+x perlscript.pl

or the equivalent commands in your FTP program.

If all other things were equal, i.e., you didn't change the access rights to the file or the file's location or file's name, then I would have to guess something has happened on the server side to cause the problem. Again (unfortunately) that's a call to the server support folks...

Good luck!