mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-19 18:38:55 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@128942 c90b9560-bf6c-de11-be94-00142212c4b1
221 lines
6.9 KiB
XML
221 lines
6.9 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.17 $ -->
|
|
<reference id="ref.image">
|
|
<title>Image functions</title>
|
|
<titleabbrev>Image</titleabbrev>
|
|
|
|
<partintro>
|
|
<section id="image.intro">
|
|
&reftitle.intro;
|
|
<para>
|
|
PHP is not limited to creating just HTML output. It can also be
|
|
used to create and manipulate image files in a variety of different
|
|
image formats, including gif, png, jpg, wbmp, and xpm. Even more
|
|
convenient, PHP can output image streams directly to a browser. You
|
|
will need to compile PHP with the GD library of image functions for
|
|
this to work. GD and PHP may also require other libraries, depending
|
|
on which image formats you want to work with.
|
|
</para>
|
|
<para>
|
|
You can use the image functions in PHP to get the size of
|
|
<acronym>JPEG</acronym>, <acronym>GIF</acronym>,
|
|
<acronym>PNG</acronym>, <acronym>SWF</acronym>,
|
|
<acronym>TIFF</acronym> and <acronym>JPEG2000</acronym> images.
|
|
</para>
|
|
<para>
|
|
<note>
|
|
<simpara>
|
|
Read requirements section about how to expand image capabilities
|
|
to read, write and modify images and to read meta data of pictures
|
|
taken by digital cameras.
|
|
</simpara>
|
|
</note>
|
|
</para>
|
|
</section>
|
|
|
|
<section id="image.requirements">
|
|
&reftitle.required;
|
|
<para>
|
|
If you have the <acronym>GD</acronym> library (available at <ulink
|
|
url="&url.gd;">&url.gd;</ulink>) you will also be able to create
|
|
and manipulate images.
|
|
</para>
|
|
<para>
|
|
The format of images you are able to manipulate depend on the
|
|
version of <acronym>GD</acronym> you install, and any other libraries
|
|
<acronym>GD</acronym> might need to access those image formats.
|
|
Versions of <acronym>GD</acronym> older than gd-1.6
|
|
support GIF format images, and do not support PNG, where versions
|
|
greater than gd-1.6 support PNG, not GIF.
|
|
<note>
|
|
<simpara>
|
|
Since PHP 4.3 there is a bundled version of the GD lib. This bundled
|
|
version has some additional features like alpha blending, and should
|
|
be used in preference to the external library
|
|
since it's codebase is better maintained and more stable.
|
|
</simpara>
|
|
</note>
|
|
</para>
|
|
<para>
|
|
You may wish to enhance GD to handle more image formats.
|
|
<table>
|
|
<title>Supported image formats</title>
|
|
<tgroup cols="3">
|
|
<thead>
|
|
<row>
|
|
<entry>Image format</entry>
|
|
<entry>Library to download</entry>
|
|
<entry>Notes</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry><literal>gif</literal></entry>
|
|
<entry></entry>
|
|
<entry>
|
|
Only supported in GD versions older than gd-1.6. <emphasis>Read-only
|
|
</emphasis> GIF support is available with PHP 4.3.0 and the bundled
|
|
GD-library.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>jpeg-6b</literal></entry>
|
|
<entry><ulink url="&url.jpeg;">&url.jpeg;</ulink></entry>
|
|
<entry></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>png</literal></entry>
|
|
<entry><ulink url="&url.libpng;">&url.libpng;</ulink></entry>
|
|
<entry>
|
|
Only supported in GD versions greater than gd-1.6.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>xpm</literal></entry>
|
|
<entry><ulink url="&url.libxpm;">&url.libxpm;</ulink></entry>
|
|
<entry>
|
|
It's likely you have this library already available, if your system
|
|
has an installed X-Environment.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</para>
|
|
|
|
<para>
|
|
You may wish to enhance GD to deal with different fonts. The following
|
|
font libraries are supported:
|
|
<table>
|
|
<title>Supported font libraries</title>
|
|
<tgroup cols="3">
|
|
<thead>
|
|
<row>
|
|
<entry>Font library</entry>
|
|
<entry>Download</entry>
|
|
<entry>Notes</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry><literal>FreeType 1.x</literal></entry>
|
|
<entry><ulink url="&url.freetype;">&url.freetype;</ulink></entry>
|
|
<entry></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>FreeType 2</literal></entry>
|
|
<entry><ulink url="&url.freetype;">&url.freetype;</ulink></entry>
|
|
<entry></entry>
|
|
</row>
|
|
<row>
|
|
<entry><literal>T1lib</literal></entry>
|
|
<entry><ulink url="&url.t1lib;">&url.t1lib;</ulink>)</entry>
|
|
<entry>
|
|
Support for Type 1 fonts.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</para>
|
|
|
|
<para>
|
|
If you have PHP compiled with <option role="configure">--enable-exif</option>
|
|
you are able to work with information stored in headers of
|
|
<acronym>JPEG</acronym> and <acronym>TIFF</acronym> images. This way you can
|
|
read meta data generated by digital cameras as mentioned above. These
|
|
functions does not require the <acronym>GD</acronym> library.
|
|
<note>
|
|
<simpara>
|
|
PHP does not require any additional library for the exif module.
|
|
</simpara>
|
|
</note>
|
|
</para>
|
|
</section>
|
|
|
|
&reference.image.configure;
|
|
|
|
&reference.image.ini;
|
|
|
|
<section id="image.resources">
|
|
&reftitle.resources;
|
|
&no.resource;
|
|
</section>
|
|
|
|
&reference.image.constants;
|
|
|
|
<section id="image.examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>PNG creation with PHP</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
header("Content-type: image/png");
|
|
$string = $_GET['text'];
|
|
$im = imagecreatefrompng("images/button1.png");
|
|
$orange = imagecolorallocate($im, 220, 210, 60);
|
|
$px = (imagesx($im) - 7.5 * strlen($string)) / 2;
|
|
imagestring($im, 3, $px, 9, $string, $orange);
|
|
imagepng($im);
|
|
imagedestroy($im);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
This example would be called from a page with a tag like: <img
|
|
src="button.php?text=text">. The above button.php script
|
|
then takes this "text" string and overlays it on top of a
|
|
base image which in this case is "images/button1.png"
|
|
and outputs the resulting image. This is a very convenient way to
|
|
avoid having to draw new button images every time you want to
|
|
change the text of a button. With this method they are
|
|
dynamically generated.
|
|
</para>
|
|
</section>
|
|
</partintro>
|
|
|
|
&reference.image.functions;
|
|
|
|
</reference>
|
|
<!-- 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
|
|
-->
|