php-doc-en/reference/image/functions/imagecreatefromgif.xml
Christoph M. Becker 213fbd9440
Remove obsolete info regarding libgd < 2.1.0
As of PHP 7.0.0, libgd ≥ 2.1.0 is required anyway.
2021-12-06 17:51:26 +01:00

137 lines
3.4 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.imagecreatefromgif" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>imagecreatefromgif</refname>
<refpurpose>&gd.image.new;</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type class="union"><type>GdImage</type><type>false</type></type><methodname>imagecreatefromgif</methodname>
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
</methodsynopsis>
<para>
<function>imagecreatefromgif</function> returns an image identifier
representing the image obtained from the given filename.
</para>
<caution>
<para>
When reading GIF files into memory, only the first frame
is returned in the image object. The size of the image is not
necessarily what is reported by <function>getimagesize</function>.
</para>
</caution>
&tip.fopen-wrapper;
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>filename</parameter></term>
<listitem>
<para>
Path to the GIF image.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>&gd.return.identifier;</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>8.0.0</entry>
<entry>
On success, this function returns a <classname>GDImage</classname> instance now;
previously, a <type>resource</type> was returned.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title>Example to handle an error during loading of a GIF</title>
<programlisting role="php">
<![CDATA[
<?php
function LoadGif($imgname)
{
/* Attempt to open */
$im = @imagecreatefromgif($imgname);
/* See if it failed */
if(!$im)
{
/* Create a blank image */
$im = imagecreatetruecolor (150, 30);
$bgc = imagecolorallocate ($im, 255, 255, 255);
$tc = imagecolorallocate ($im, 0, 0, 0);
imagefilledrectangle ($im, 0, 0, 150, 30, $bgc);
/* Output an error message */
imagestring ($im, 1, 5, 5, 'Error loading ' . $imgname, $tc);
}
return $im;
}
header('Content-Type: image/gif');
$img = LoadGif('bogus.image');
imagegif($img);
imagedestroy($img);
?>
]]>
</programlisting>
&example.outputs.similar;
<mediaobject>
<alt>Output of example : Example to handle an error during loading of a GIF</alt>
<imageobject>
<imagedata fileref="en/reference/image/figures/imagecreatefromgif.gif"/>
</imageobject>
</mediaobject>
</example>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->