note 58836 deleted from ref.image by tularis
| From: | tularis@php.net | Date: | Sun, 29 Jun 2008 21:04:04 +0000 |
| Subject: | note 58836 deleted from ref.image by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-140933@lists.php.net to get a copy of this message | ||
Note Submitter: Jonas Sweden
----
Simple script for getting a jpg-thumb by submitting imgname and either height or width of the thumb!
<?php
if(isset($_GET["i"]) && ("" != $_GET["i"])){
$fn = "path/to/jpgs/".$_GET["i"].".jpg";
if(false !== (list($ws,$hs) = @getimagesize($fn))){
if(isset($_GET["w"]) && ("" != $_GET["w"])){
$ratio = ((float)$_GET["w"]) / $ws;
}
elseif(isset($_GET["h"]) && ("" != $_GET["h"])){
$ratio = ((float)$_GET["h"]) / $hs;
}
if(isset($ratio)){
$wt = $ws * $ratio;
$ht = $hs * $ratio;
$thumb = imagecreatetruecolor($wt,$ht);
$source = imagecreatefromjpeg($fn);
imagecopyresampled($thumb,$source,0,0,0,0,$wt,$ht,$ws,$hs);
header('Content-type: image/jpeg');
imagejpeg($thumb);
imagedestroy($thumb);
}
}
}
?>