#! /usr/bin/perl use strict; use warnings; use Image::Size; use LWP::Simple; use CGI; my $cgi = new CGI; my $image = $cgi->param('image'); my $contents = get($image); my ($width, $height, $error) = imgsize(\$contents); # attributes. if (($width > 300) || ($height > 300)) { if ($width > $height) { # Image is wider that it is tall ($width,$height) = (300, int((300 * $height) / $width)); }else{ # Image is taller than it is wide ($width,$height) = (int((300 * $width) / $height), 300); } } #output image print "";