<?php
###############################
## Thumbcreation script V 0.9b
## by eXtiQ 05/31/2006
## last edit 10/15/2006
###############################
/*
* Usage:
* Example: thumb.php?bild=%Filename to an image%
* This will output an 100px width and propotional height sized image.
* You can use wether .gif , .jpg or .png
*/
if(isset($_GET['picture'])) ## Check, if $_GET Attribute is set
{
$img = htmlspecialchars($_GET['picture']);
if (!get_magic_quotes_gpc())
{
addslashes($img);
}
if (trim(substr($img,0,7)) == "http://" or trim(substr($img,0,6)) == "ftp://")
{
DIE("Denied");
}
$type = getimagesize($img);
switch($type[2]) ## Switch the Imagetype, written in index 2
{
case 1 : $picture = imagecreatefromgif($img); $typ = 1; break; ## gif
case 2 : $picture = imagecreatefromjpeg($img); $typ = 2; break; ## jpg
case 3 : $picture = imagecreatefrompng($img); $typ = 3; break; ## png
default : echo "Not a JPG/GIF/PNG file";
}
$width = imagesx($picture); ## get width of the image
$height = imagesy($picture); ## get height of the image
$nwidth = 100; ## define new width
$nheight = round(($height / $width) * 100); ## define new height
$thumb = imagecreate($nwidth, $nheight); ## create new empty image
imagecopyresized($thumb,$picture,0,0,0,0,$nwidth,$nheight,$width,$height); ## copy thumbnail into new image
## Send header information to the browser ##
header ("HTTP/1.1 200 OK", true);
header ("Date: ". gmdate("D, d M Y H:i:s GTM"), true);
header ("Server: Apache/2.0.55", true);
header ("Accept-Ranges: bytes", true);
switch($typ)
{
case 1 :
{
header ("Content-Type: image/gif", true);
imagegif($thumb,"",100);
break;
}
case 2 :
{
header ("Content-Type: image/jpg", true);
imagejpeg($thumb,"",100);
break;
}
case 3 :
{
header ("Content-Type: image/png", true);
imagejpeg($thumb,"",100);
break;
}
default : echo "Error: No Filetype";
}
imagedestroy($thumb);
}
?>