note 58836 added to ref.image
| From: | JonasSweden at osu1 dot php dot net | Date: | Thu, 17 Nov 2005 11:51:10 +0000 |
| Subject: | note 58836 added to ref.image | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-98703@lists.php.net to get a copy of this message | ||
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);
}
}
}
?>
----
Manual Page -- http://www.php.net/manual/en/ref.image.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+58836
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58836&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58836&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58836&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58836&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58836&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58836&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58836&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+58836&report=yes
Search -- http://master.php.net/manage/user-notes.php