open (TMP, ">/tmp/test.jpg"); my $file = upload('thefile'); my $image = GD::Image->newFromJpeg($file); my ($x, $y) = $image->getBounds(); my $new_image = new GD::Image(800, 600); $new_image->copyResized($image, 0, 0, 0, 0, 800, 600, $image->getBounds); binmode(TMP); print TMP $new_image->jpeg;