<?php
require_once('config.php');
$src = isset($_REQUEST['src']) ? urldecode($_REQUEST['src']) : null;
// we're using file_exists here to prevent working with remote files if(isset($src) && file_exists($src)) { header('Content-Type: image/jpeg');
list($width, $height, $type, $attr) = getimagesize($src); $img = imagecreatefromjpeg($src); $lowest = min(THMBWIDTH / $width, THMBHEIGHT / $height);
if($lowest < 1) { $smallwidth = floor($lowest*$width); $smallheight = floor($lowest*$height); $tmp = imagecreatetruecolor($smallwidth, $smallheight); imagecopyresized($tmp, $img, 0, 0, 0, 0, $smallwidth, $smallheight, $width, $height); imagedestroy($img); $img = $tmp; } imagejpeg($img, '', 100); imagedestroy($img); }
?> |