$_REQUEST['w'] OR ($height/$faktor) > $_REQUEST['h']){ $faktor2 = ($height/$faktor) / $_REQUEST['h']; } $destwidth = floor($width / ($faktor*$faktor2)); $destheight = floor($height / ($faktor*$faktor2)); //echo "ws: {$width} hs: {$height} wr: {$_REQUEST['w']} hr: {$_REQUEST['h']} wd: {$destwidth} hd: {$destheight}"; $r = 255; // Red color value (0-255) $g = 255; // Green color value (0-255) $b = 255; // Blue color value (0-255) switch($size['mime']){ case "image/jpeg": header("Content-type: {$size['mime']}"); $src = imagecreatefromjpeg($_REQUEST['img']); $dest = imagecreatetruecolor($destwidth,$destheight); imagecopyresized($dest,$src,0,0,0,0,$destwidth,$destheight,$width,$height); imagejpeg($dest); imagedestroy($dest); imagedestroy($src); break; case "image/gif": header("Content-type: image/png"); $src=ImageCreateFromGIF($_REQUEST['img']); $dest=imagecreatetruecolor($destwidth,$destheight); $th_bg_color = imagecolorallocate($dest, $r, $g, $b); imagefill($dest, 0, 0, $th_bg_color); imagecolortransparent($dest, $th_bg_color); ImageCopyResized($dest,$src,0,0,0,0,$destwidth,$destheight,$width,$height); ImagePNG($dest); imagedestroy($dest); imagedestroy($src); break; case "image/png": header("Content-type: {$size['mime']}"); $src=ImageCreateFromPNG($_REQUEST['img']); $dest=imagecreatetruecolor($destwidth,$destheight); $th_bg_color = imagecolorallocate($dest, $r, $g, $b); imagefill($dest, 0, 0, $th_bg_color); imagecolortransparent($dest, $th_bg_color); ImageCopyResized($dest,$src,0,0,0,0,$destwidth,$destheight,$width,$height); ImagePNG($dest); imagedestroy($dest); imagedestroy($src); break; } ?>