php-doc-en/reference/image/functions/imagecreatefromgif.xml
Christoph Michael Becker 099a58be24 Fix bug #75788: getimagesize() for GIF
We clarify the details regarding the image size reported by
getimagesize() for GIFs vs. the actual size of images created by
imagecreatefromgif().

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@343841 c90b9560-bf6c-de11-be94-00142212c4b1
2018-01-15 13:58:49 +00:00

124 lines
3.1 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>resource</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 resource pointer. 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="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>
<refsect1 role="notes">
&reftitle.notes;
<note>
<para>
GIF support was removed from the GD library in Version 1.6,
and added back in Version 2.0.28. This function is not
available between these versions.
</para>
</note>
</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
-->