<?
$src = $_SERVER["DOCUMENT_ROOT"].$_REQUEST['src'];
$width = $_REQUEST['width'];
$img = @imagecreatefromjpeg($src);
$photoInfo = @getimagesize($src);
if ($width*1 > $photoInfo[0]*1) {
header('Content-Type: image/jpeg');
imagejpeg($img);
}
else {
$height = ($width * $photoInfo[1]) / $photoInfo[0];
$imgResize = imageCreateTrueColor($width, $height);
imageCopyResampled($imgResize, $img, 0, 0, 0, 0,
$width, $height, $photoInfo[0], $photoInfo[1]);
header('Content-Type: image/jpeg');
imagejpeg($imgResize);
}
?>
|