resizing an image with the gd library
am 20.11.2007 02:51:26 von yawnmoth
I'm trying to resize an image with the gd library and am having some
difficulty. Here's my code:
$img = 'http://upload.wikimedia.org/wikipedia/commons/e/e3/Kheops-
Pyramid.jpg';
list($width, $height) = getimagesize($img);
$img = imagecreatefromjpeg($img);
$temp = imagecreate(500, 500);
imagecopyresized($img, $temp, 0, 0, 0, 0, 500, 500, $width, $height);
header('Content-type: image/jpeg');
imagejpeg($temp);
?>
All I get is a 500x500 black picture. What I don't get is a resized
wikimedia.org picture. Any ideas as to what I'm doing wrong?
Re: resizing an image with the gd library
am 20.11.2007 05:11:51 von yawnmoth
On Nov 19, 8:06 pm, ljb wrote:
> terra1...@yahoo.com wrote:
> > I'm trying to resize an image with the gd library and am having some
> > difficulty. Here's my code:
>
> >
>
> > $img = 'http://upload.wikimedia.org/wikipedia/commons/e/e3/Kheops-
> > Pyramid.jpg';
> > list($width, $height) = getimagesize($img);
> > $img = imagecreatefromjpeg($img);
>
> > $temp = imagecreate(500, 500);
> > imagecopyresized($img, $temp, 0, 0, 0, 0, 500, 500, $width, $height);
>
> > header('Content-type: image/jpeg');
> > imagejpeg($temp);
> > ?>
>
> > All I get is a 500x500 black picture. What I don't get is a resized
> > wikimedia.org picture. Any ideas as to what I'm doing wrong?
>
> Check usage on imagecopyresized. I think you switched source and
> destination, i.e. you copied your fresh blank image over onto the pyramid
> image.
That was it - thanks!