if($gd_test != "no")
{
$size = getimagesize($_GET["img"]);
$width_org = $size[0];
$height_org = $size[1];
$imagetype = $size[2];
switch ($imagetype)
{
case 1: // GIF
$img_org = imagecreatefromgif($_GET["img"]);
break;
case 2: // JPG
$img_org = imagecreatefromjpeg($_GET["img"]);
break;
case 3: // PNG
$img_org = imagecreatefrompng($_GET["img"]);
break;
default:
create_text_image("Unsupported imageformat.");
}
if(isset($img_org))
{
if(isset($_GET["prozent"]))
{
$width_new = $size[0] * $_GET["prozent"];
$height_new = intval($height_org * $width_new / $width_org);
}
else
{
if(isset($_GET["_width"]) && isset($_GET["_height"]))
{
$width_new = $_GET["_width"];
$height_new = $_GET["_height"];
}
}
if(isset($width_new) && isset($height_new))
{
$img_new = imagecreate($width_new, $height_new);
imagecopyresized($img_new, $img_org, 0, 0, 0, 0, $width_new, $height_new, $width_org, $height_org);
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Expires: Mon, 28 Dec 1981 01:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
switch ($imagetype)
{
case 1: // GIF
header("Content-type: image/gif");
imagegif($img_new);
break;
case 2: // JPG
header("Content-type: image/jpeg");
imagejpeg($img_new, "", 100);
break;
case 3: // PNG
header("Content-type: image/png");
imagepng($img_new);
break;
create_text_image("Unsupported imageformat.");
}
}
else
create_text_image("Error creating image.");
}
}
function create_text_image($text)
{
$im = imagecreate(120, 120);
$bgc = imagecolorallocate($im, 255, 255, 255);
$tc = imagecolorallocate ($im, 255, 0, 0);
imagefilledrectangle($im, 0, 0, 110, 110, $bgc);
// Output an errmsg
imagestring($im, 4, 5, 45, $text, $tc);
header("Content-type: image/gif");
imagegif($_img);
}