imagecreatefromjpeg help.
| From: | DazzaL | Date: | Thu, 08 Nov 2001 00:26:04 +0000 |
| Subject: | imagecreatefromjpeg help. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-73828@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'm using that works 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);
?>