$x = $image->Read($localfile);
You are not reading any data in.
The following is a partial listing from some code I use often enough. Look for ## <-- LOOK AT ME below to see how to only get a single image.
Note: this code is not tested per se, it is ripped from working code. But it should get you on the right path.
my $remotefile = param("image"); ## you need to read in the data from the uploaded file my $data; { local $/; $data = <$remotefile>; } ## directory is defined above ## name is defined above, dependings on what sort of naming convention + you want ## magick is defined above my $saveFile = "${directory}${$name}.${magick}"; #begin image magick my ($image, $x); $image=Image::Magick->new or die( 'my error message' ); $image->BlobToImage($data); ## read uploaded data into IM ## kill layers/pages/etc $image = $image->[0]; ## <-- LOOK AT ME $image->Flatten(); ## i don't know why art directors hate uploadin +g flattened images, but they do.. #$x = $image->Resize(width=>500, height=>500); ## scale the image if I need to ## hardcoded 500s! my ( $hRatio, $wRatio ) = ( 500 / $image->Get( 'rows' ), 500 / $image- +>Get( 'columns' ) ); unless ( $hRatio > 1 and $wRatio > 1 ) { ## + image is smaller than limits my $multiplier = $hRatio < $wRatio ? $hRatio : $wRatio ; $image->Scale( height => int( $image->Get('rows') * $multi +plier ), width => int( $image->Get('columns') * $multi +plier ) ); } ## explicitly set the magick $image->Set( 'magick' => $magick ); $x = $image->Write( $saveFile ); warn "$x" if "$x";

Will perl for money
JJ Knitis


In reply to Re: Saving the first frame of any image by gt8073a
in thread Saving the first frame of any image by Anonymous Monk

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.