|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I'm trying to resize an image with the gd library and am having some
difficulty. Here's my code: <?php $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? |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
terra1024@yahoo.com wrote:
> I'm trying to resize an image with the gd library and am having some > difficulty. Here's my code: > ><?php > > $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. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Nov 19, 8:06 pm, ljb <lba...@pobox.com.nospam> 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: > > ><?php > > > $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! |
|
![]() |
| Outils de la discussion | |
|
|