<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.image.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'es',
  ),
  'this' => 
  array (
    0 => 'function.imagecreatefromgif.php',
    1 => 'imagecreatefromgif',
    2 => 'Crear una nueva imagen a partir de un archivo o una URL',
  ),
  'up' => 
  array (
    0 => 'ref.image.php',
    1 => 'Funciones de GD e Im&aacute;genes',
  ),
  'prev' => 
  array (
    0 => 'function.imagecreatefromgd2part.php',
    1 => 'imagecreatefromgd2part',
  ),
  'next' => 
  array (
    0 => 'function.imagecreatefromjpeg.php',
    1 => 'imagecreatefromjpeg',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'es',
    'path' => 'reference/image/functions/imagecreatefromgif.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.imagecreatefromgif" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imagecreatefromgif</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">imagecreatefromgif</span> &mdash; <span class="dc-title">Crear una nueva imagen a partir de un archivo o una URL</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.imagecreatefromgif-description">
  <h3 class="title">Descripción</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imagecreatefromgif</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$filename</code></span>): <span class="type"><span class="type"><a href="class.gdimage.php" class="type GdImage">GdImage</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>imagecreatefromgif()</strong></span> devuelve un identificador de imagen que
   representa la imagen obtenida a partir del fichero cuyo nombre es
   dado por <code class="parameter">filename</code>.
  </p>
  <div class="caution"><strong class="caution">Precaución</strong>
   <p class="para">
    Al leer en memoria ficheros GIF animados, solo el primer frame
    es devuelto por el objeto de la imagen. El tamaño de la imagen no
    es necesariamente el que se reporta mediante <span class="function"><a href="function.getimagesize.php" class="function">getimagesize()</a></span>.
   </p>
  </div>
  <div class="tip"><strong class="tip">Sugerencia</strong><p class="simpara">
 Puede utilizar una URL como nombre de archivo con esta función, si el
 <a href="filesystem.configuration.php#ini.allow-url-fopen" class="link">gestor fopen</a> ha sido activado. Véase <span class="function"><a href="function.fopen.php" class="function">fopen()</a></span>
 para más detalles sobre cómo especificar el nombre del archivo. Consulte
 <a href="wrappers.php" class="xref">Protocolos y Envolturas soportados</a> para más información sobre las capacidades de los diferentes gestores,
 las notas sobre su uso, así como la información sobre las variables predefinidas que proporcionan.
</p></div>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.imagecreatefromgif-parameters">
  <h3 class="title">Parámetros</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">filename</code></dt>
     <dd>
      <p class="para">
       Ruta hacia la imagen GIF.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.imagecreatefromgif-returnvalues">
  <h3 class="title">Valores devueltos</h3>
  <p class="para">Devuelve un objeto de imagen en caso de éxito, <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> en caso de error.</p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.imagecreatefromgif-changelog">
  <h3 class="title">Historial de cambios</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Versión</th>
      <th>Descripción</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       En caso de éxito, esta función devuelve ahora una instancia de
       <span class="classname"><a href="class.gdimage.php" class="classname">GDImage</a></span> ; anteriormente,
       se devolvía un <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.imagecreatefromgif-examples">
  <h3 class="title">Ejemplos</h3>
  <div class="example" id="example-1">
   <p><strong>Ejemplo #1 Ejemplo de manejo de errores al cargar una imagen GIF</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">LoadGif</span><span style="color: #007700">(</span><span style="color: #0000BB">$imgname</span><span style="color: #007700">)<br />{<br />    </span><span style="color: #FF8000">/* Intenta abrir la imagen */<br />    </span><span style="color: #0000BB">$im </span><span style="color: #007700">= @</span><span style="color: #0000BB">imagecreatefromgif</span><span style="color: #007700">(</span><span style="color: #0000BB">$imgname</span><span style="color: #007700">);<br /><br />    </span><span style="color: #FF8000">/* Procesamiento si la apertura falló */<br />    </span><span style="color: #007700">if(!</span><span style="color: #0000BB">$im</span><span style="color: #007700">)<br />    {<br />        </span><span style="color: #FF8000">/* Creación de una imagen vacía */<br />        </span><span style="color: #0000BB">$im </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecreatetruecolor </span><span style="color: #007700">(</span><span style="color: #0000BB">150</span><span style="color: #007700">, </span><span style="color: #0000BB">30</span><span style="color: #007700">);<br />        </span><span style="color: #0000BB">$bgc </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecolorallocate </span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">255</span><span style="color: #007700">, </span><span style="color: #0000BB">255</span><span style="color: #007700">, </span><span style="color: #0000BB">255</span><span style="color: #007700">);<br />        </span><span style="color: #0000BB">$tc </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecolorallocate </span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /><br />        </span><span style="color: #0000BB">imagefilledrectangle </span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">150</span><span style="color: #007700">, </span><span style="color: #0000BB">30</span><span style="color: #007700">, </span><span style="color: #0000BB">$bgc</span><span style="color: #007700">);<br /><br />        </span><span style="color: #FF8000">/* Muestra un mensaje de error en la imagen */<br />        </span><span style="color: #0000BB">imagestring </span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">5</span><span style="color: #007700">, </span><span style="color: #0000BB">5</span><span style="color: #007700">, </span><span style="color: #DD0000">'Error loading ' </span><span style="color: #007700">. </span><span style="color: #0000BB">$imgname</span><span style="color: #007700">, </span><span style="color: #0000BB">$tc</span><span style="color: #007700">);<br />    }<br /><br />    return </span><span style="color: #0000BB">$im</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">'Content-Type: image/gif'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$img </span><span style="color: #007700">= </span><span style="color: #0000BB">LoadGif</span><span style="color: #007700">(</span><span style="color: #DD0000">'bogus.image'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">imagegif</span><span style="color: #007700">(</span><span style="color: #0000BB">$img</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <div class="example-contents"><p>Resultado del ejemplo anterior es similar a:</p></div>
   <div class="mediaobject">
    
    <div class="imageobject">
     <img src="images/21009b70229598c6a80eef8b45bf282b-imagecreatefromgif.gif" alt="Visualización del ejemplo: imagecreatefromgif()" width="150" height="30" />
    </div>
   </div>
  </div>
 </div>

</div><?php manual_footer($setup); ?>