#!/usr/bin/perl # # imagetest.cgi v1.01 by Encodable Industries # http://encodable.com/test_imagemagick_and_gd_perl_modules/ # use CGI::Carp 'fatalsToBrowser'; print "Content-type: text/html\n\n"; eval { require Image::Magick; }; my $im_error = $@; if($im_error) { print "The Image::Magick Perl module is not properly installed. "; print "I tried to load it, which resulted in this error:
\n$@

\n\n"; } else { print "The Image::Magick Perl module loaded properly.

\n\n"; if(-e 'testpic.jpg') { eval { my $image = new Image::Magick; my ($width,$height,$size,$format) = $image->Ping('testpic.jpg'); print "ImageMagick Test: image width = " . $width . ".
\n"; }; if($@) { print "I tried to use the ImageMagick Perl module, "; print "but it gave this error:
\n$@

\n\n"; } else { print "I successfully used the ImageMagick Perl module.

\n\n"; } } else { print "You must put an image file called testpic.jpg in the "; print "same folder as this script to test ImageMagick's functionality.

\n\n"; } } print "--------------------------------------------------

\n\n"; eval { require GD; require GD::Simple; }; my $gd_error = $@; if($gd_error) { print "The GD (or GD::Simple) Perl module is not properly installed. "; print "I tried to load it, which resulted in this error:
\n$@

\n\n"; } else { print "The GD (and GD::Simple) Perl module loaded properly.

\n\n"; if(-e 'testpic.jpg') { eval { my $image = GD::Image->new('testpic.jpg'); print "GD Test: image width = " . $image->width . ".
\n"; }; if($@) { print "I tried to use the GD Perl module, "; print "but it gave this error:
\n$@

\n\n"; } else { print "I successfully used the GD Perl module.

\n\n"; } } else { print "You must put an image file called testpic.jpg in the "; print "same folder as this script to test GD's functionality.

\n\n"; } } print "--------------------------------------------------

\n\n"; my $convert_command = 'convert'; if(`$convert_command -version` =~ /image.*magick/i) { print "The ImageMagick 'convert' command appears to be installed on "; print "your system, so you may be able to use that directly, instead "; print "of using the ImageMagick Perl module or the GD Perl module.

\n\n"; } else { print "The ImageMagick 'convert' command does not appear to be installed "; print "on your system, or at least, its location is not specified within "; print "your system's PATH environment variable, so it didn't execute when "; print "we tried to call it. If you're on Windows, you may need to go into "; print "the ImageMagick program files folder and rename convert.exe to "; print "something else, like imgconv.exe, because some versions of Windows "; print "already have a different convert command (a disk utility) which "; print "will get executed when you call 'convert'.

\n\n"; } print "Manually searching for 'convert' executable:

\n\n"; print "/usr/bin/convert " . (-f "/usr/bin/convert" ? "exists" : "does not exist") . ".
\n"; print "/usr/local/bin/convert " . (-f "/usr/local/bin/convert" ? "exists" : "does not exist") . ".
\n"; print "
\n"; print "--------------------------------------------------

\n\n"; print "Done.

\n\n"; print qq`http://encodable.com/test_imagemagick_and_gd_perl_modules/
\n`;