This little script create an thumbnail from an jpeg-image. To use it, use an link in form of thumb.php?url=path_to_big_image.jpg with little changes it will create png-thumbnails.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <?
header ("Content-type: image/jpeg"); # We will create an *.jpg
$pic = @imagecreatefromjpeg($url) or die ("Image not found!");
if ($pic) {
$width = imagesx($pic);
$height = imagesy($pic);
$twidth = 160; # width of the thumb 160 pixel
$theight = $twidth * $height / $width; # calculate height
$thumb = @imagecreatetruecolor ($twidth, $theight) or
die ("Can't create Image!");
imagecopyresized($thumb, $pic, 0, 0, 0, 0,
$twidth, $theight, $width, $height); # resize image into thumb
ImageJPEG($thumb,"",75); # Thumbnail as JPEG
}
?>
|
Tags: graphics