I am trying to open a remote URL .jpg file and then resize this image.
The image is stored in
$imgbuffer
Using the following script, I am able to open, read and output the original size of the remote file but when I try to resize the image it's throwing an error.
Any advice would be greatly appreciated.
Thank you,
Tony Ritter
..............................................
<?
$fh = fopen('http://www.foo.com/bar.jpg', 'r');
if ($fh) {
$imgbuffer = null;
while ($chunk = fread($fh, 1000000))
$imgbuffer .= $chunk;
fclose($fh);
} // o.k. to here...
$new_w=300;
$new_h=300;
$dst_img=ImageCreate($new_w,$new_h);
$src_img=ImageCreateFromJpeg($imgbuffer);
ImageCopyResized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img),ImageSY($src_img));
ImageJpeg($dst_img);
echo $dst_img;
?>