geektron has asked for the wisdom of the Perl Monks concerning the following question:

I've been fighting with this for a few hours now, and I'm stuck. I've reread docs, but can't really find anything relevant to this error from Image::Magick::Read:
Exception 450: Empty input file (/var/tmp/magic81OnytHVZvna2f.tmp)

I'm trying to use an uploaded image, resize if needed, and save to a new directory. Earlier, I adapted the code to not depend on CGI's  upload method because i wasn't getting anywhere with it ....

so here's the code in question:

my $thumb = Image::Magick->new(); open( THUMBFILE, $tmpName ) or die "Can't open tmpImg $tmpName: $ +! \n";; my $filesRead = $thumb->Read( file => \*THUMBFILE ); close THUMBFILE; print STDERR "Read: $filesRead files \n"; my ( $height, $width ) = $thumb->Get( 'height', 'width' );
if the files weren't where i say it is via  $tmpName , the OPEN statement should die. and i've verified on the filesystem, and it's there, alright, and ~400K.

without the GLOB ref, strict complains that barewords aren't allowed.

the location reference in the error isn't the same as the file location, but i presume it should be different because of the OPEN statement ....

i'm willing to entertain just about any possiblity, from a b0rked Image::Magick/ Perl::Magick install to .... but how would i check for a b0rked install?

Replies are listed 'Best First'.
Re: Image::Magick woes
by tachyon (Chancellor) on Sep 05, 2003 at 03:56 UTC

    You are using an undocumented bit of the interface (but the docs are sparse). Does this not work? It works fine for me.

    use Image::Magick; my $tmpName = 'd:/proxy/html/images/email.gif'; my $thumb = Image::Magick->new(); $thumb->Read( $tmpName ); my ( $height, $width ) = $thumb->Get( 'height', 'width' ); print "$tmpName: $height h $width w\n"; __DATA__ d:/proxy/html/images/email.gif: 14 h 14 w

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      i yanked what i'm doing straight outta the docs.

      i'm leaning towards b0rked install ... because it works intermittantly, and/or only for JPGs.

      i'm going to fight more ... i guess

      thanks

      blurge. that works fine ... thanks again.

      i wish i understood why the filehandle version wasn't working, though. it's *in* the Image::Magick does ( the web version ), so it's documented.....

        You are right it is on their site, just not in the main docs. It does not work because it is not correctly implemented (obviously). You can see the implementation in Magick.xs and if you know a bit of C and perlguts you can probably work out why. Follow the callback trail through Read->SetupList->GetList. I just can't really see that syntax implemented anywhere. In practical terms you need to look for the string 'file' as this is a plain SV but so is '/path/to/file.gif' which is a path to a real file. The => is just a comma. But I only had a very quick look.

        It is a BUG so you should report it. Either a doc bug or a code bug depending on how you want to look at it.

        cheers

        tachyon

        s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print