perlmagick imagemagick error

1.6k Views Asked by At

My hosting provider has recently upgraded their servers and I am having lots of problems with imagemagick scripts in perl. My script worked perfectly on the old server but fail on the new one so I have gone back to basics to try and sort out what is going wrong.

The server reports the imagemagick as:

Version: ImageMagick 6.7.2-2 2011-10-20 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP

and the perl module Image::Magick is version 6.72

The following script is saved on my server:

#!/usr/bin/perl 
use CGI::Carp qw( fatalsToBrowser );

use Image::Magick;

my $image = Image::Magick->new;

$x = $image -> Set(size=>"200x200");
warn "$x" if "$x";

$x = $image -> ReadImage("canvas:black");
warn "$x" if "$x";

$x = $image -> Draw (
  stroke    => "red",
  primitive => "line",
  points    => "20,20 180,180");
warn "$x" if "$x";

print "Content-type: image/gif\n\n";
binmode STDOUT;
$image -> write ("gif:-");

This fails with the following errors:

[Sun Oct 23 11:02:32 2011] imtest.pl: Exception 420: no decode delegate for this image format `lack' @ error/constitute.c/ReadImage/532 at www/11/cgi-bin/imtest.pl line 12.
[Sun Oct 23 11:02:32 2011] imtest.pl: Exception 410: no images defined `Draw' @ error/Magick.xs/XS_Image__Magick_Mogrify/7394 at www/11/cgi-bin/imtest.pl line 18.

If I change ReadImage("canvas:black") to ReadImage("xc:black") then the script runs continuously with no output.

My webhost has been great in trying to find a solution but I need to know if I am doing something wrong here, or if there is an installation problem with imagemagick.

Please note I realise the above can be done with other simpler modules but this is just a simple example to determine if the problem is imagemagick or my code!

Thanks for your help.

Regards,

Stu

1

There are 1 best solutions below

1
On

I received similar errors in winxp command line mode with version 6.3.7 of ImageMagick.

I changed the first few lines to this and it worked:

my $image = Image::Magick->new(size=>"200x200");
die "Image::Magick->new failed" unless $image;

my $x = $image->Read("xc:black");
warn "$x" if "$x";