$maxwidth) { $width = $maxwidth; $height = 0; } // Resize if image height is more than maxheight if ($maxheight and $size[1] > $maxheight) { $height = $maxheight; $width = 0; } if ($size[2] != '1' and $size[2] != '2' and $size[2] != '3') exit(); if ($size[2] == '1') $ext = '.gif'; if ($size[2] == '2') $ext = '.jpg'; if ($size[2] == '3') $ext = '.png'; if ($size[2] == '1') $img = imagecreatefromgif ($_GET["fn"]); if ($size[2] == '2') $img = imagecreatefromjpeg ($_GET["fn"]); if ($size[2] == '3') $img = imagecreatefrompng ($_GET["fn"]); $k1 = 0; if ($width and $height) { $k1 = $size[0]/$width; $k2 = $size[1]/$height; $k = min($k1, $k2); $im_bg = imagecreatetruecolor ($width, $height); imagecopyresized($im_bg, $img, 0, 0, round(($size[0] - $width*$k)/2), round(($size[1] - $height*$k)/2), $size[0]/$k, $size[1]/$k, $size[0], $size[1]); } elseif ($width) { $k1 = $size[0]/$width; $im_bg = imagecreatetruecolor ($size[0]/$k1, $size[1]/$k1); imagecopyresized($im_bg, $img, 0, 0, 0, 0, $size[0]/$k1, $size[1]/$k1, $size[0], $size[1]); } elseif ($height) { $k1 = $size[1]/$height; $im_bg = imagecreatetruecolor ($size[0]/$k1, $size[1]/$k1); imagecopyresized($im_bg, $img, 0, 0, 0, 0, $size[0]/$k1, $size[1]/$k1, $size[0], $size[1]); } else { $im_bg = $img; } if ($size[2] == '1') header('Content-Type: image/gif'); if ($size[2] == '2') header('Content-Type: image/jpeg'); if ($size[2] == '3') header('Content-Type: image/png'); if ($size[2] == '1') imagegif($im_bg); if ($size[2] == '2') imagejpeg($im_bg, '', 100); if ($size[2] == '3') imagepng($im_bg); imagedestroy($im_bg); ?>