jeudi 2 avril 2015

Upload an image to server and resize with Perl+GD

I upload image by CGI. Then I need recize it and save to server.



my $q=new CGI;
my $photo=$q->param('photo'); # it is uploaded image by html form


Then I don't understand how to convert $photo for GD needed type?



$image = GD::Image->newFromJpeg($photo); # create a new image


Then I recize it:



my ($ox, $oy) = $image->getBounds();
my ($nx, $ny) = (800, 600);
my $outimage = new GD::Image($nx, $ny);
$outimage->copyResized($image, 0, 0, 0, 0, $nx, $ny, $ox, $oy);

Aucun commentaire:

Enregistrer un commentaire