<?php
// useage is thumbnail.php?im=imagename.jpg
// set for 120 px thumb
$im=$_GET['imgname'];
Header("Content-type: image/jpeg");
$orig_image = imagecreatefromjpeg($im);
list($width, $height, $type, $attr) = getimagesize($im);
if ($width > 120) {
$ratio = 120 / $width;
$newheight = $ratio * $height; }
else $newheight = $height;
$sm_image = imagecreatetruecolor(120,$newheight) or die ("Cannot Initialize new gd image stream");;
Imagecopyresampled($sm_image,$orig_image,0,0,0,0,120,$newheight,imagesx($orig_image),imagesy($orig_image));
imageJPEG($sm_image);
imagedestroy($sm_image);
imageDestroy($orig_image);
?>
//Usage
$t="thumbnail.php?imgname=images/1.jpg";
<img src=".$t.">
No comments:
Post a Comment