PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > resizing an image with the gd library
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
resizing an image with the gd library

Réponse
 
LinkBack Outils de la discussion
Vieux 20/11/2007, 02h51   #1
yawnmoth
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut resizing an image with the gd library

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?
  Réponse avec citation
Vieux 20/11/2007, 03h06   #2
ljb
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: resizing an image with the gd library

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.
  Réponse avec citation
Vieux 20/11/2007, 05h11   #3
yawnmoth
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: resizing an image with the gd library

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!
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 09h43.


Édité par : vBulletin®
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,35587 seconds with 11 queries