I’m trying to add a watermark to a image using Image::Magic, bot I keep on getting this error
Can't call method "Read" on an undefined value at ImageUploader.pl line xxx.
Witch is:
$Logo->Read('../Data/Images/Watermark.png');
in the code below and can not figure it out the path is right and the file exists.
Any ideas?
use Image::Magick;
my $NewImage = Image::Magick->new;
$NewImage->Read("../Data/Temp/Images/$SaveAs$Extension");
my ($Width,$Height) = $NewImage->Get('width','height'); # find dimensions
my $ResizedWidth = 275;
my $ResizedHeight = 450;
my $MeduimThumbnailWidth = 300;
my $MeduimThumbnailHeight = 300;
if($Height >= $ResizedHeight){
my $ResizedHeight = int($Height * ($ResizedWidth / $Width));
$Logo->Read('../Data/Images/Watermark.png');
$NewImage->Composite(compose=>'blend', blend=>'50x50', x=>'50', y=>'50', image=>$Logo,);
$NewImage->Resize(width=>$ResizedWidth, height=>$ResizedHeight);
$NewImage->Write("../Data/Images/$URL/$SaveAs\_lrg$Extension");
}else{
$NewImage->Write("../Data/Images/$URL/$SaveAs\_lrg$Extension");
}
$Logois undefined because you never assign a value to it.Presumably you are missing:
You are also missing:
… which should appear in all modern Perl programmes.