2002-04-15 00:12:54 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2002-10-09 08:32:05 +00:00
|
|
|
<!-- $Revision: 1.11 $ -->
|
2002-04-15 00:12:54 +00:00
|
|
|
<reference id="ref.image">
|
|
|
|
<title>Image functions</title>
|
|
|
|
<titleabbrev>Image</titleabbrev>
|
|
|
|
|
|
|
|
<partintro>
|
2002-05-29 17:34:10 +00:00
|
|
|
<section id="image.intro">
|
2002-10-08 17:53:21 +00:00
|
|
|
&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>
|
2002-05-29 17:34:10 +00:00
|
|
|
<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>
|
2002-08-28 11:58:59 +00:00
|
|
|
<para>
|
|
|
|
<note>
|
2002-08-28 18:28:39 +00:00
|
|
|
<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>
|
2002-08-28 11:58:59 +00:00
|
|
|
</note>
|
|
|
|
</para>
|
2002-05-29 17:34:10 +00:00
|
|
|
</section>
|
|
|
|
|
2002-08-09 10:26:12 +00:00
|
|
|
<section id="image.requirements">
|
2002-05-29 17:34:10 +00:00
|
|
|
&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.
|
2002-08-28 11:58:59 +00:00
|
|
|
<note>
|
2002-08-28 18:28:39 +00:00
|
|
|
<simpara>
|
2002-09-26 13:56:54 +00:00
|
|
|
Since PHP 4.3 there is a bundled version of the GD lib. This bundled
|
2002-08-28 18:28:39 +00:00
|
|
|
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>
|
2002-08-28 11:58:59 +00:00
|
|
|
</note>
|
2002-05-29 17:34:10 +00:00
|
|
|
</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
|
2002-08-28 11:58:59 +00:00
|
|
|
<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.
|
2002-08-29 09:48:09 +00:00
|
|
|
<note>
|
|
|
|
<simpara>
|
|
|
|
PHP does not require any additional library for exif the module.
|
|
|
|
</simpara>
|
|
|
|
</note>
|
2002-05-29 17:34:10 +00:00
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section id="image.installation">
|
|
|
|
&reftitle.install;
|
|
|
|
<para>
|
|
|
|
In order to read and write images in jpeg format, you will need to
|
|
|
|
obtain and install jpeg-6b (available at
|
|
|
|
<ulink url="&url.jpeg;">&url.jpeg;</ulink>), and then recompile
|
|
|
|
<acronym>GD</acronym> to make use of jpeg-6b. You will also have to
|
|
|
|
compile PHP with
|
|
|
|
<option role="configure">--with-jpeg-dir=/path/to/jpeg-6b</option>.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
To add support for Type 1 fonts, you can install t1lib (available
|
|
|
|
at <ulink url="&url.t1lib;">&url.t1lib;</ulink>), and then add
|
|
|
|
<option role="configure">--with-t1lib[=dir]</option>.
|
|
|
|
</para>
|
|
|
|
</section>
|
2002-09-12 20:32:50 +00:00
|
|
|
|
|
|
|
&reference.image.ini;
|
2002-05-29 17:34:10 +00:00
|
|
|
|
|
|
|
<section id="image.resources">
|
|
|
|
&reftitle.resources;
|
|
|
|
&no.resource;
|
|
|
|
</section>
|
|
|
|
|
|
|
|
&reference.image.constants;
|
|
|
|
|
2002-10-08 17:53:21 +00:00
|
|
|
<section id="image.examples">
|
|
|
|
&reftitle.examples;
|
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title>PNG creation with PHP</title>
|
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
header("Content-type: image/png");
|
2002-10-09 08:32:05 +00:00
|
|
|
$string = $_GET['text'];
|
2002-10-08 17:53:21 +00:00
|
|
|
$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">. 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>
|
2002-04-15 00:12:54 +00:00
|
|
|
</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
|
|
|
|
-->
|
|
|
|
|