$width = $_GET['width'];
$height= $_GET['height'];
$filename = $_GET['file'];
if ($ext == "jpg") {
header('Content-type: image/jpeg'); } else if ($ext == "png") {
header('Content-type: image/png'); } else if ($ext == "gif") {
header('Content-type: image/gif'); }
$ratio_orig = $width_orig / $height_orig;
if ($width_orig < $varwidth) {
$width = $width_orig;
$height = $height_orig;
} else {
if ($width / $height > $ratio_orig) {
$width = $height * $ratio_orig;
} else {
$height = $width / $ratio_orig;
}
}
$image_p = imagecreatetruecolor($width, $height);
$white = imagecolorallocate($image_p, 255, 255, 255);
imagefill($image_p, 0, 0,
$white);
if ($ext == "jpg") {
$image = imagecreatefromjpeg($filename);
} else if ($ext == "png") {
$image = imagecreatefrompng($filename);
} else if ($ext == "gif") {
$image = imagecreatefromgif($filename);
}
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
if ($ext == "jpg") {
imagejpeg($image_p, NULL, 100);
} else if ($ext == "png") {
imagepng($image_p);
} else if ($ext == "gif") {
imagegif($image_p, NULL, 100);
}