<HTML ><HEAD ><TITLE >ImageCreateFromGif</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.44"><LINK REL="HOME" TITLE="PHP Manual" HREF="manual.html"><LINK REL="UP" TITLE="Image functions" HREF="ref.image.html"><LINK REL="PREVIOUS" TITLE="ImageCreate" HREF="function.imagecreate.html"><LINK REL="NEXT" TITLE="ImageDashedLine" HREF="function.imagedashedline.html"></HEAD ><BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.imagecreate.html" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.imagedashedline.html" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.imagecreatefromgif" >ImageCreateFromGif</A ></H1 ><DIV CLASS="refnamediv" ><A NAME="AEN11786" ></A >ImageCreateFromGif -- create a new image from file or URL</DIV ><DIV CLASS="refsect1" ><A NAME="AEN11789" ></A ><H2 >Description</H2 ><DIV CLASS="funcsynopsis" ><P ></P ><CODE CLASS="FUNCDEF" >int imagecreatefromgif</CODE >(string filename);<P ></P ></DIV ><P > <B CLASS="function" >imagecreatefromgif()</B > returns an image identifier representing the image obtained from the given filename.</P ><P > <B CLASS="function" >imagecreatefromgif()</B > returns an empty string on failure. It also outputs an error message, which unfortunately displays as a broken link in a browser. To ease debugging the following example will produce an error GIF: <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><P ><B >Example 1. Example to handle an error during creation (courtesy vic@zymsys.com )</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="programlisting" > 1 2 function LoadGif($imgname) 3 { 4 $im = @imagecreatefromgif($imgname); /* Attempt to open */ 5 if ($im == "") { /* See if it failed */ 6 $im = ImageCreate(150,30); /* Create a blank image */ 7 $bgc = ImageColorAllocate($im,255,255,255); 8 $tc = ImageColorAllocate($im,0,0,0); 9 ImageFilledRectangle($im,0,0,150,30,$bgc); 10 ImageString($im,1,5,5,"Error loading $imgname",$tc); /* Output an errmsg */ 11 } 12 return $im; 13 } 14 </PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > <DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note: </B > Since all GIF support was removed from the GD library in version 1.6, this function is not available if you are using that version of the GD library.</P ></BLOCKQUOTE ></DIV ></P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.imagecreate.html" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="manual.html" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.imagedashedline.html" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >ImageCreate</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.image.html" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >ImageDashedLine</TD ></TR ></TABLE ></DIV ></BODY ></HTML >