Image functions Image
&reftitle.intro; 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. You can use the image functions in PHP to get the size of JPEG, GIF, PNG, SWF, TIFF and JPEG2000 images. 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.
&reftitle.required; If you have the GD library (available at &url.gd;) you will also be able to create and manipulate images. The format of images you are able to manipulate depend on the version of GD you install, and any other libraries GD might need to access those image formats. Versions of GD 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. 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. You may wish to enhance GD to handle more image formats. Supported image formats Image format Library to download Notes gif Only supported in GD versions older than gd-1.6. Read-only GIF support is available with PHP 4.3.0 and the bundled GD-library. jpeg-6b &url.jpeg; png &url.libpng; Only supported in GD versions greater than gd-1.6. xpm &url.libxpm; It's likely you have this library already available, if your system has an installed X-Environment.
You may wish to enhance GD to deal with different fonts. The following font libraries are supported: Supported font libraries Font library Download Notes FreeType 1.x &url.freetype; FreeType 2 &url.freetype; T1lib &url.t1lib;) Support for Type 1 fonts.
If you have PHP compiled with you are able to work with information stored in headers of JPEG and TIFF images. This way you can read meta data generated by digital cameras as mentioned above. These functions does not require the GD library. PHP does not require any additional library for exif the module.
&reference.image.configure; &reference.image.ini;
&reftitle.resources; &no.resource;
&reference.image.constants;
&reftitle.examples; PNG creation with PHP ]]> 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.
&reference.image.functions;