★ wanayoo — archive 1999 http://www.php.net/manual/fr/function.imagecreatefromgif.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Graphisme
Quick Reference
English version of this pageGerman version of this pageJapanese version of this pageItalian version of this pageHungarian version of this page
Graphisme
* GetImageSize
* ImageArc
* ImageChar
* ImageCharUp
* ImageColorAllocate
* ImageColorAt
* ImageColorClosest
* ImageColorExact
* ImageColorResolve
* ImageColorSet
* ImageColorsForIndex
* ImageColorsTotal
* ImageColorTransparent
* ImageCopyResized
* ImageCreate
* ImageCreateFromGif
* ImageDashedLine
* ImageDestroy
* ImageFill
* ImageFilledPolygon
* ImageFilledRectangle
* ImageFillToBorder
* ImageFontHeight
* ImageFontWidth
* ImageGif
* ImageInterlace
* ImageLine
* ImageLoadFont
* ImagePolygon
* ImagePSBBox
* ImagePSEncodeFont
* ImagePSFreeFont
* ImagePSLoadFont
* ImagePSText
* ImageRectangle
* ImageSetPixel
* ImageString
* ImageStringUp
* ImageSX
* ImageSY
* ImageTTFBBox
* ImageTTFText
Manual: ImageCreateFromGif
View the source code for this pageSearch the site



Previous page
 ImageCreate
 Updated
Sun, 06 Aug 2000
ImageDashedLine 
Next page


ImageCreateFromGif

(unknown)

ImageCreateFromGif -- Crée une nouvelle image à partir d'un fichier ou d'une URL.

Description

int imagecreatefromgif (string filename)

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

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ébuggage, utilisez le code suivant, qui retourne une erreur GIF :

Exemple 1. Exemple de gestion des erreurs durant création d'image (gracieusement offert par courtesy vic@zymsys.com )


function LoadGif($imgname)
{
  $im = @imagecreatefromgif($imgname); /* Tentative d'ouverture */
  if ($im == "") { /* Echec ? */
    $im = ImageCreate(150,30); /* Crée une image vide */
    $bgc = ImageColorAllocate($im,255,255,255);
    $tc  = ImageColorAllocate($im,0,0,0);
    ImageFilledRectangle($im,0,0,150,30,$bgc);
    ImageString($im,1,5,5,"Erreur lors du chargement du fichier $imgname",$tc); /* Affiche un message d'erreur */
  }
  return $im;
}

Note: Etant donné que toutes les fonctions de gestion des GIF ont été supprimées de la bibliothèque GD version 1.6, cette fonction n'est pas disponible si vous utilisez cette version de la librairie.


User Contributed Notes: ImageCreateFromGif


snippy@stampede.org
01-Aug-1999 11:51
It would appear the description is wrong in declaring that the return is of type 'int' if the return is actually a string non?


dpetrov@nchcapital.cm
26-Aug-1999 03:37
Support for PNG images was added to GD with the removal of GIF support. Latest patches for PHP 3.0 add new functions, in particular ImageCreateFromPng() and ImagePng(). At the time of writing, for some odd reason, PHP 4.0 does NOT have these functions.


odeen@gmx.de
27-Aug-1999 09:47
it would be nice, if there were a similar function to load a *.png file or a *.jpg file to manipulate it. Now it is not possible to make buttons on the fly. that was the best of ypur grafik stuff




mgrphp3@cgocable.net
02-Oct-1999 04:37
There is nothing that prevents a user from installing and using a version of gd that supports .gif format images (version 1.3 thru 1.5). These libs are still widely available. If you install one of these versions, php will add the gif support. If you have 1.6 or above installed, php will _not_ add it.


velner@museco.com
30-Oct-1999 07:08
I have installed PHP with some problems. Finaly I succed but now if I
try to restart apache I get:
"Cannot load /etc/httpd/modules/libphp3.so into server:
/etc/httpd/modules/libphp3.so: undefined symbol: gdImageCreateFromGif.

Do anyone maybe know what I could have done wrong or what I didn't do to get this thing work?

Thank's for an answer

Velner




09-Dec-1999 07:22
I had the same problem when installing PHP3. I figured out, that since GD dropped gif support, php3 will sometimes compile incorrectly. So, to fix it, I edited the gd.c file (located in your php3-src/functions directory), and changed the calls ImageGif and CreateImageFromGif to ImagePng and CreateImageFromPng.


anthony.atkins@vt.edu
03-Feb-2000 05:49
The documentation says you can use a URL but there are no examples and the logical syntax ( $image = CreateImageFromGif($URL);) doesn't work. Ugh.


anthony.atkins@vt.edu
16-May-2000 06:05
<pre>
function myImageCreateFromGif($file_or_url) {

$dummy_file = "/tmp/dummy.gif";

# if this is a url, use fopen to get the file data, then
# save it to a dummy file
if (preg_match("/(http|ftp):\/\//i", $file_or_url)) {
# open the file using fopen, which supports remote URLs
$input = fopen($file_or_url, "rb");

# read the contents of the file
# will accept files up to 10Mb, but will probably get
# and EOF before that, we have to do it this way because
# filesize isn't designed to work with URLs. sigh.
$image_data = fread($input, 10000000);

fclose($input);

# write the contents to a dummy file
$output = fopen("$dummy_file", "wb");
fwrite($output, $image_data);
fclose($output);

# create the gif from the dummy file
$image = ImageCreateFromGif($dummy_file);

# get rid of the dummy file
unlink($dummy_file);

}

# if it's not a URL, we can simply open the image directly
else {
$image = ImageCreateFromGif($file_or_url);
}

if ($image) { return $image; }
else { return 0; }
}


if (!$url) { $url = "http://scholar.lib.vt.edu/images/cornholio.gif";}
$image = myImageCreateFromGif($url);

if ($image == "" || $image == 0) {
print "

No Image data was returned...

\n";
}
else {
header("Content-Type: image/gif\n\n");
ImageGif($image);
}

?>
</pre>



 About Notes


Previous page
 ImageCreate
 Updated
Sun, 06 Aug 2000
ImageDashedLine 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.