Page 1 of 1

Error435/Can't read from a filename contained in array/var

Posted: 2010-08-22T08:37:04-07:00
by timothy
Hi all, I'm very much a perl newbie, so apologies if this turns out to be a perl problem and not strictly and perlmagick one..

I can get the following to work without issue:

Code: Select all

$teampath = "/var/www/team1";
$player=Image::Magick->new;
$imgpath = $teampath . "/img/player.png";
$player->Read("$imgpath")
..but really I want $imagepath to be an element of an array (because I intend to iterate through the array). However, this wont work for me:

Code: Select all

$teampath = "/var/www/team1";
$player=Image::Magick->new;
$imgpath = $teampath . "/img/" . $images[0];
$player->Read("$imgpath")
It simply wont read the image.

@images is a properly defined array with 16 elements:

Code: Select all

print "$imgpath\n";
Produces the following in either!! of the above cases:
/var/www/team1/img/player.png
Any ideas what I'm doing wrong folks? :(

Re: Can't read from filename contained in array element..?

Posted: 2010-08-23T11:34:08-07:00
by timothy
I have a little further info.. The ImageMagick Error Code is:
435 - Blob - A binary large object could not be allocated, read, or written
I didn't really realise it was a blob I was working with.. Is this important?

The code has evolved slightly and now looks like this (The problem remains the same):

Code: Select all

 foreach my $image(@images) {
                my($imgpath) = join "", $teampath, '/img/', "$image"; #Replacing "$image" with an actual filename fixes the problem.#
                #print "$imgpath\n";
                $player=Image::Magick->new;
                my($x) = $player->Read($imgpath);
                warn "$x" if "$x";    # print the error message
                $x =~ /(\d+)/;
                print $1;               # print the error number