in reply to Saving the first frame of any image
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Saving the first frame of any image
by coldfingertips (Pilgrim) on Mar 25, 2004 at 18:59 UTC | |
by TilRMan (Friar) on Mar 26, 2004 at 02:29 UTC |