Chapter 7. Graphics Support in PHP

2 views
Skip to first unread message

Pterodactyl

unread,
May 9, 2007, 4:58:11 PM5/9/07
to Dive Into PHP 5: The Graphics
Chapter 7. Graphics Support in PHP

Table of Contents

History
PHP Extensions
PEAR Image Packages
Third-Party Applications

This chapter lets you know what exact graphics features are supported
in PHP.

History

Graphics support was added to PHP far before PHP 5. Let us call to
mind some out of dated PHP extensions mentioned in old books [9]
[http://pterodactyl.l2p.net/book/php5image/page/
bi01.html#programming.php].

Imlib2 Extension. This extension loads, saves, and modificates images;
draws primitives, gradients, and text [13][http://pterodactyl.l2p.net/
book/php5image/page/bi01.html#php.imlib2]. It is not supported in PHP
5 any more.

GD Extension. Versions of GD older than gd-1.6 support GIF format
images, and do not support PNG, where versions greater than gd-1.6 and
less than gd-2.0.28 support PNG, not GIF. [2][http://
pterodactyl.l2p.net/book/php5image/page/http://pterodactyl.l2p.net/
book/php5image/page/bi01.html#php_manual]

[Note][http://pterodactyl.l2p.net/images/docbook/note.png] Note

Often the newer GD2 extension (gd-2.x) is referred as just GD too.

SWF Extension. This extension has been moved to the PECL repository
and is no longer bundled with PHP as of PHP 5.0.0. It offers the
ability to create Shockwave Flash files. [2][http://
pterodactyl.l2p.net/book/php5image/page/bi01.html#php_manual]

PHP Extensions

Exif Extension. With this extension you are able to work with image
meta data - for example, to read meta data of pictures taken from
digital cameras by working with information stored in the image
headers. [2][http://pterodactyl.l2p.net/book/php5image/page/
bi01.html#php_manual]

GD2 Extension. It can be used to create and manipulate image files in
a variety of different image formats, including GIF, PNG, JPEG, WBMP,
and XPM as well as output image streams directly to a browser. Since
PHP 4.3 there is a bundled version of the GD library. This bundled
version has some additional features like alpha blending [2][http://
pterodactyl.l2p.net/book/php5image/page/bi01.html#php_manual]

[Note][http://pterodactyl.l2p.net/images/docbook/note.png] Note

Often the GD2 extension (gd-2.x) is referred as just GD.

Ming Extension. This open-source library allows you to create SWF
(Flash) format movies. Ming supports almost all of Flash 4's features,
including: shapes, gradients, bitmaps (PNG and JPEG), morphs ("shape
tweens"), text, buttons, actions, sprites ("movie clips"), streaming
MP3, and color transforms - the only thing that's missing is sound
events. [2][http://pterodactyl.l2p.net/book/php5image/page/
bi01.html#php_manual]

PEAR Image Packages

PEAR provides about a dozen and a half packages for working with
images. [3][http://pterodactyl.l2p.net/book/php5image/page/
bi01.html#pear_manual]

Image_3D allows the rendering of 3 dimensional objects utilizing PHP.

Image_Barcode provides barcode generation.

Image_Canvas is a package providing a common interface to image
drawing, making image source code independent on the library used.

Image_Color manages and handles color data and conversions, whereas
Image_Color2 offers color conversion and mixing for PHP 5.

Image_GIS provides visualization of GIS data and Image_IPTC extracts,
modifies, and saves IPTC data.

Image_Graph is a package for displaying (numerical) data as a graph/
chart/plot and Image_GraphViz is an interface to AT&T's GraphViz
tools.

Image_MonoBMP manipulates monochrome BMP images, Image_WBMP
manipulates WBMP images, and Image_XBM manipulates XBM images.

Image_Puzzle generates puzzle pieces from image file.

Image_Remote retrieves information on remote image files.

Image_Text allows advanced text manipulations in images.

Image_Tools is a tools collection for image manipulation.

Image_Transform provides a standard interface to manipulate images
using different libraries.

Third-Party Applications

ImageMagick. It is an open source image manipulation and display
software suite supporting a wide variety of formats [1][http://
pterodactyl.l2p.net/book/php5image/page/bi01.html#wikipedia].
ImageMagick is a software suite to create, edit, and compose bitmap
images. It can read, convert and write images in a variety of formats
(about 100). Use ImageMagick to translate, flip, mirror, rotate,
scale, shear and transform images, adjust image colors, apply various
special effects, or draw text, lines, polygons, ellipses and Bezier
curves. [14][http://pterodactyl.l2p.net/book/php5image/page/
bi01.html#imagemagick.intro]

Netpbm. It is an open source package of graphics programs and a
programming library, used mainly in the Unix world [1][http://
pterodactyl.l2p.net/book/php5image/page/bi01.html#wikipedia]. Netpbm
is a toolkit for manipulation of graphic images, including conversion
of images between a variety of different formats. There are over 220
separate tools in the package including converters for about 100
graphics formats. Examples of the sort of image manipulation are:
shrinking an image by 10%; cutting the top half off of an image;
making a mirror image; creating a sequence of images that fade from
one image to another; and so on. [15][http://pterodactyl.l2p.net/book/
php5image/page/bi01.html#netpbm.readme]

Also there are dozens more web based tools written in PHP, especially
numerous image galleries and photo albums - from LIMP (Lightweight
Image-Browser for PHP) to Gallery. Many of them allows automatic
thumbnails, resizing, rotation, and more.

Reply all
Reply to author
Forward
0 new messages