imagecreatefromgd2part
<<<
imagecreatefromgif imagecreatefromjpeg
>>>

6.14 Images
6 Référence des fonctions
 Manuel PHP

Introduction
Pré-requis
Installation
Configuration à l'exécution
Types de ressources
Constantes pré-définies
Exemples
gd_info
getimagesize
image_type_to_extension
image_type_to_mime_type
image2wbmp
imagealphablending
imageantialias
imagearc
imagechar
imagecharup
imagecolorallocate
imagecolorallocatealpha
imagecolorat
imagecolorclosest
imagecolorclosestalpha
imagecolorclosesthwb
imagecolordeallocate
imagecolorexact
imagecolorexactalpha
imagecolormatch
imagecolorresolve
imagecolorresolvealpha
imagecolorset
imagecolorsforindex
imagecolorstotal
imagecolortransparent
imageconvolution
imagecopy
imagecopymerge
imagecopymergegray
imagecopyresampled
imagecopyresized
imagecreate
imagecreatefromgd
imagecreatefromgd2
imagecreatefromgd2part
->imagecreatefromgif
imagecreatefromjpeg
imagecreatefrompng
imagecreatefromstring
imagecreatefromwbmp
imagecreatefromxbm
imagecreatefromxpm
imagecreatetruecolor
imagedashedline
imagedestroy
imageellipse
imagefill
imagefilledarc
imagefilledellipse
imagefilledpolygon
imagefilledrectangle
imagefilltoborder
imagefilter
imagefontheight
imagefontwidth
imageftbbox
imagefttext
imagegammacorrect
imagegd
imagegd2
imagegif
imageinterlace
imageistruecolor
imagejpeg
imagelayereffect
imageline
imageloadfont
imagepalettecopy
imagepng
imagepolygon
imagepsbbox
imagepscopyfont
imagepsencodefont
imagepsextendfont
imagepsfreefont
imagepsloadfont
imagepsslantfont
imagepstext
imagerectangle
imagerotate
imagesavealpha
imagesetbrush
imagesetpixel
imagesetstyle
imagesetthickness
imagesettile
imagestring
imagestringup
imagesx
imagesy
imagetruecolortopalette
imagettfbbox
imagettftext
imagetypes
imagewbmp
imagexbm
iptcembed
iptcparse
jpeg2wbmp
png2wbmp

6.14.44 imagecreatefromgif() Crée une nouvelle image à partir d'un fichier ou d'une URL

[ Exemples avec imagecreatefromgif ]   PHP 3, PHP 4, PHP 5

resource  imagecreatefromgif ( string   filename )

imagecreatefromgif retourne un identifiant d'image qui représente l'image obtenue à partir du fichier dont le nom est donné par filename .

imagecreatefromgif retourne une chaîne vide en cas d'échec. Il va aussi retourner une erreur qui va afficher un lien brisé dans un navigateur. Pour simplifier le débogage, utilisez le code suivant, qui retourne une erreur GIF :
Exemple de gestion des erreurs durant la création d'image

<?php
function LoadGif ($imgname) {
    
$im = @imagecreatefromgif ($imgname); /* Tentative d'ouverture */
    
if (!$im) { /* Test d'échec */
        
$im = imagecreatetruecolor (150, 30); /* Création d'une image vide */
        
$bgc = imagecolorallocate ($im, 255, 255, 255);
        
$tc = imagecolorallocate ($im, 0, 0, 0);
        
imagefilledrectangle ($im, 0, 0, 150, 30, $bgc);
        
/* Affichage d'un message d'erreur */
        
imagestring ($im, 1, 5, 5, "Erreur au chargement de l'image $imgname", $tc);
    }
    return
$im;
}
?>
Note

Le support du GIF a été supprimé de la bibliothèque GD dans sa verison 1.6 et a été rajouté depuis la version 2.0.28. Cette fonction n'est donc pas disponible entre ces deux verisons.

Array
Attention

Les versions Windows de PHP antérieureus à la version 4.3.0 ne supportent pas l'accès aux fichiers distants avec cette fonction, même si allow_url_fopen est activé.

<< imagecreatefromgif >>
imagecreatefromgd2part Images imagecreatefromjpeg