note 16650 rejected from function.imagecreatefromjpeg by jimw
| From: | jimw@php.net | Date: | Thu, 08 Nov 2001 00:08:36 +0000 |
| Subject: | note 16650 rejected from function.imagecreatefromjpeg by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-20585@lists.php.net to get a copy of this message | ||
Im trying to use imagecreatefromjpeg to retrieve an image off another website and make an thumbnail
out of it, is this possible?
heres the code that I can use as long as the image is on the same server.
<?php
// we expect $hSize and $image to be defined, having been passed to us via
// query string. $vSize will generated to maintain aspect ratio.
$image = realpath ("") . $image;
// create an image object from the source file
$srcImg = imagecreatefromjpeg($image);
// create a (blank) smaller image object
$srcSize = getimagesize($image);
$vRatio = $hSize / $srcSize[0]; // percentage
$vSize = $srcSize[1]* $vRatio;
$dstImg = imagecreate($hSize, $vSize);
// copy and resize from the source image object to the smaller blank one
imagecopyresized($dstImg, $srcImg, 0, 0, 0, 0,$hSize, $vSize,$srcSize[0], $srcSize[1]);
// send the smaller image object to the browser
header( "Content-Type: image/jpeg");
imagejpeg($dstImg);
// clean up
imagedestroy($scrImg);
imagedestroy($dstImg);
?>