php-doc-en/reference/image/functions/imagegif.xml
Etienne Kneuss 990a7c732c NULL value as a filename
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@218859 c90b9560-bf6c-de11-be94-00142212c4b1
2006-08-25 17:33:25 +00:00

125 lines
4.1 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.12 $ -->
<!-- splitted from ./en/functions/image.xml, last change in rev 1.3 -->
<refentry id="function.imagegif">
<refnamediv>
<refname>imagegif</refname>
<refpurpose>Output image to browser or file</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>imagegif</methodname>
<methodparam><type>resource</type><parameter>image</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>filename</parameter></methodparam>
</methodsynopsis>
<para>
<function>imagegif</function> creates the <acronym>GIF</acronym>
file in filename from the image <parameter>image</parameter>. The
<parameter>image</parameter> argument is the return from the
<function>imagecreate</function> or <literal>imagecreatefrom*</literal>
function.
</para>
<para>
The image format will be <acronym>GIF87a</acronym> unless the
image has been made transparent with
<function>imagecolortransparent</function>, in which case the
image format will be <acronym>GIF89a</acronym>.
</para>
<para>
The filename argument is optional, and if left off or filled
with a &null; value, the raw image stream will be output directly.
By sending an image/gif content-type using <function>header</function>,
you can create a PHP script that outputs <acronym>GIF</acronym>
images directly.
<note>
<para>
Since all <acronym>GIF</acronym> support was removed from the
<acronym>GD</acronym> library in version 1.6, this function is
not available if you are using that version of the GD library.
Support is expected to return in a version subsequent to the
rerelease of <acronym>GIF</acronym> support in the GD library in
mid 2004. For more information, see the
<ulink url="&url.gd;">GD Project</ulink> site.
</para>
<para>
The following code snippet allows you to write more
portable PHP applications by auto-detecting the
type of GD support which is available. Replace
the sequence <literal>header ("Content-type: image/gif");
imagegif ($im);</literal> by the more flexible sequence:
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
if (function_exists("imagegif")) {
header("Content-type: image/gif");
imagegif($im);
} elseif (function_exists("imagejpeg")) {
header("Content-type: image/jpeg");
imagejpeg($im, "", 0.5);
} elseif (function_exists("imagepng")) {
header("Content-type: image/png");
imagepng($im);
} elseif (function_exists("imagewbmp")) {
header("Content-type: image/vnd.wap.wbmp");
imagewbmp($im);
} else {
die("No image support in this PHP server");
}
?>
]]>
</programlisting>
</informalexample>
</para>
</note>
<note>
<para>
As of version 3.0.18 and 4.0.2 you can use the function
<function>imagetypes</function> in place of
<function>function_exists</function> for checking
the presence of the various supported image formats:
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
if (imagetypes() & IMG_GIF) {
header ("Content-type: image/gif");
imagegif ($im);
} elseif (imagetypes() & IMG_JPG) {
/* ... etc. */
}
?>
]]>
</programlisting>
</informalexample>
</para>
</note>
</para>
<para>
See also <function>imagepng</function>, <function>imagewbmp</function>,
<function>imagejpeg</function> and <function>imagetypes</function>.
</para>
</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:"../../../../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
-->