Code: Select all
$BasePath = str_repeat("../", substr_count(dirname($_SERVER["PHP_SELF"]), "/"));
require ($BasePath."includes/config.php");
define(thumbnailWidth, "50");
header("Content-type: image/jpeg");
$filename = $server_path.$HTTP_GET_VARS["filename"];
$source = imagecreatefromjpeg($filename);
$thumbX = thumbnailWidth;
$imageX = imagesx($source);
$imageY = imagesy($source);
$thumbY = (int)(($thumbX*$imageY) / $imageX );
$dest = imagecreatetruecolor($thumbX, $thumbY);
imagecopyresampled ($dest, $source, 0, 0, 0, 0, $thumbX, $thumbY, $imageX, $imageY);
imagejpeg($dest);
imagedestroy($dest);
imagedestroy($source);I am calling the script like this
Code: Select all
echo "<img src="/includes/admin/thumbnail.php?filename=".$result['path']."" alt="what you want"/>";