Hey monks, I've been using "perlmagic" and I get the following error:

Error reading file /websites/phorm/www/pics/animals/shippo.gif No such file or directory at /websites/snowbunny/cgi-bin//gallery.cgi line 53

(not sure what's with the //gallery.cgi, that's a seperate issue though) The code is using "perlmagick" in an attempt to create an image montage, as below. I've checked as the www-data (apache) user and can DEFINATELY read the file in question.
#!/usr/bin/perl use CGI; use Image::Magick; use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; $magick=Image::Magick->new(); $images=Image::Magick->new(); ######## my $basepath = "/websites/snowbunny/www"; my $path = $cgi->url_param("path"); my %filetypes; $filetypes{jpg}="jpeg"; $filetypes{gif}="gif"; #### $path =~ tr/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345 +6789\ \_\-\///c; $path =~ s/\/\///gis; $path =~ s/\.\.//gis; $path = "gallery1/dec_2004"; my $fullpath = "$basepath/$path"; #Just in case the cgi path was mangled, but it isn't!!! $fullpath="/websites/phorm/www/pics/animals"; if ( -d $fullpath ) { opendir(DIR, "$fullpath"); @files = readdir(DIR); my @pictures; my $picture_count; foreach $file(@files) { # warn("Checking $file"); if ($file =~ /\.([\w\d]+)$/) { $extension = lc($1); if ( defined($filetypes{$extension} ) ) { my $filepath = "$fullpath/$file"; #$filepath =~ s/\ /\\\ /gi; $pictures[$picture_count] = Image::Magick->new(); warn("# of pictures: " . @$images); open (IMAGE_IN, "<$filepath") or die("Cannot read file $filepa +th\n$!"); #pictures[$picture_indx] = $pictures[$picture_count]->ReadImag +e("$filepath") or die("Cannot read $filepath"); # $pictures[$picture_indx] = $pictures[$picture_count]->Read(fil +e=>\*IMAGE_IN) or die("Error reading file $filepath $!"); close(IMAGE_IN); $pictures[$picture_count]->Label("$filename"); push(@$images, $pictures[$picture_indx] ); $picture_count++; } } } if ( $picture_count > 0) { my $montage=$images->Montage(geometry=>'130x194+10+5>',gravity +=>'Center', bordercolor=>'green',borderwidth=>1,tile=>'5x1000',compose=> +'over', background=>'#ffffff',font=>'Generic.ttf',pointsize=>18,fi +ll=>'#600', stroke=>'none'); $montage->Set(matte=>'false'); print "Content-type: image/jpeg\n\n"; $montage->Write('jpg:-'); } else { print "Content-type: text/html\n\n"; print "no pictures in $fullpath"; } } else { die("Invalid path $fullpath"); }

In reply to PerlMagick "file not found" issues by darkphorm

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.