Manipulating POST files

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
Posts: 1
Joined: 2011-07-23T10:40:46-07:00
Authentication code: 8675308

Manipulating POST files

Post by Neilos »

How can I manipulate images submitted through a form using POST?

Basically I want to make sure that images are no bigger than a certain size (width and height) and if they are bigger than scale them down.

My first attempt was to try to get the POST image to display simply as it is recieved. I tried;

Code: Select all


use strict;
use warnings;
use Image::Magick;
use CGI;
use CGI::Carp qw(fatalsToBrowser);

my $query = CGI->new;
my $image = Image::Magick->new;

my $filename = $query->param('uploadedfile');

my $status = $image->Read( $filename );
die "Couldn't open image: $status" if $status;

binmode STDOUT;
print $query->header( -type => "image/png" );
I know that this code is way off, I need to access the file itself not the filename ($query->param('uploadedfile');) so I tried using my $filename = $query->upload('uploadedfile'); but as of yet I have had no success. Could someone tell me how this is accomplished. I was thinking that maybe I needed to access the temp file that CGI creates for the image, is that the way to go about it?

Or do I simply have to save the file to the server first and then open it?
User avatar
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Manipulating POST files

Post by anthony »

Neilos Your request is purely CGI handling, and has nothing to do with imagemagick. I suggest you look at one of teh CGI tutorial websites (there are lots of those)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
Post Reply