where path is a relative path such as subdirectory/image.jpg $thumbsize = $_GET['size']; $imagesource = $_GET['path']; $filetype = substr($imagesource,strlen($imagesource)-4,4); $filetype = strtolower($filetype); if($filetype == ".gif") $image = @imagecreatefromgif($imagesource); if($filetype == ".jpg") $image = @imagecreatefromjpeg($imagesource); if($filetype == ".png") $image = @imagecreatefrompng($imagesource); if($filetype == ".GIF") $image = @imagecreatefromgif($imagesource); if($filetype == ".JPG") $image = @imagecreatefromjpeg($imagesource); if($filetype == ".PNG") $image = @imagecreatefrompng($imagesource); if (!$image) die(); $imagewidth = imagesx($image); $imageheight = imagesy($image); if ($imagewidth >= $imageheight) { $thumbwidth = $thumbsize; $factor = $thumbsize / $imagewidth; $thumbheight = $imageheight * $factor; } if ($imageheight >= $imagewidth) { $thumbheight = $thumbsize; $factor = $thumbsize / $imageheight; $thumbwidth = $imagewidth * $factor; } $thumb = @imagecreatetruecolor($thumbwidth,$thumbheight); imagecopyresized($thumb, $image, 0, 0, 0, 0, $thumbwidth, $thumbheight, $imagewidth, $imageheight); imagejpeg($thumb); imagedestroy($image); imagedestroy($thumb); ?>