| |
Re: Error on paste/rubthrough function
From: Tony Cook (17479@xyz.molar.is)
Date: Mon 10 Dec 2007 - 05:43:33 GMT
Next message: William Kern: "Re: Error on paste/rubthrough function"
On Sun, Dec 09, 2007 at 09:24:52PM -0800, William Kern wrote:
> I have a working Imager install that happily converts file types and
> performs most other Imager functions.
>
> However, when I try the paste or rubthrough function I get the following
> error:
>
> "Can't use string ("source.gif") as a HASH ref while "strict refs" in
> use at /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Imager.pm
> line 630."
>
> The relevant code is:
>
> #!/usr/bin/perl
> use strict;
> use warnings;
> use Imager;
> my $source="source.gif";
> my $original="original.gif";
> my $Rimage = Imager->new;
> $Rimage->open(file => "$original") or die $Rimage->errstr;
> my $left = 10;
> my $top = 5;
> $Rimage->paste(left => $left, top => $top, img => $source);
> $Rimage->write(file=>'result.gif');
> exit;
>
> OS is CentOS5, but I can reproduce it on an older Trustix 2.2 runing 5.8.5.
> Again. all other Imager functionality is fine (i.e. rotate, etc).
Hi,
You need to create an Imager object for the source image too:
#!/usr/bin/perl
use strict;
use warnings;
use Imager;
my $source="source.gif";
my $original="original.gif";
# load the image
my $Simage = Imager->new;
$Simage->open(file => $source)
or die "Could not open $source: ", $Simage->errstr;
my $Rimage = Imager->new;
$Rimage->open(file => "$original") or die $Rimage->errstr;
my $left = 10;
my $top = 5;
# use the loaded image instead the filename as the source
$Rimage->paste(left => $left, top => $top, img => $Simage);
$Rimage->write(file=>'result.gif');
exit;
| |