- Add info on automatically detected/supported types. Add return

values, see alsos, and an example.


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@166184 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Dave Barr 2004-08-12 19:51:01 +00:00
parent 2e6724c835
commit b47cadeca3

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/image.xml, last change in rev 1.31 -->
<refentry id="function.imagecreatefromstring">
<refnamediv>
@ -7,14 +7,61 @@
<refpurpose>Create a new image from the image stream in the string</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
&reftitle.description;
<methodsynopsis>
<type>resource</type><methodname>imagecreatefromstring</methodname>
<methodparam><type>string</type><parameter>image</parameter></methodparam>
</methodsynopsis>
<para>
<function>imagecreatefromstring</function> returns an image identifier
representing the image obtained from the given string.
representing the image obtained from the given string. These types
will be automatically detected if your build of PHP supports them:
JPEG, PNG, GIF, WBMP, and GD2.
</para>
</refsect1>
<refsect1>
&reftitle.returnvalues;
<para>
An image resource will be returned on success. &false; is returned if
the image type is unsupported, the data is not in a recogised format,
or the image is corrupt and cannot be loaded.
</para>
</refsect1>
<refsect1>
&reftitle.seealso;
<para>
<function>imagecreatefromjpeg</function>,
<function>imagecreatefrompng</function>,
<function>imagecreatefromgif</function>&listendand;
<function>imagecreate</function>
</para>
</refsect1>
<refsect1>
&reftitle.examples;
<para>
<example>
<title><function>imagecreatefromstring</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$data = 'iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABl'
. 'BMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDr'
. 'EX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r'
. '8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg==';
$data = base64_decode($data);
$im = imagecreatefromstring($data);
if ($im !== false) {
header('Content-Type: image/png');
imagepng($im);
}
else {
echo 'An error occured.';
}
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
</refentry>