Skip to main content


developerWorks  >  Open source  >

Getting graphic with PHP

Create and manipulate images using the PHP GD library

developerWorks

Level: Intermediate

Ken Bluttman (ken@kenbluttman.com), Freelance Web Developer, Freelance Consultant

01 Jul 2008

Register now or sign in using your IBM ID and password.

Imagine creating Web-page graphics dynamically using just code — no need for a complex graphics program. Creating and manipulating images is yours for the doing with the power of PHP. Put your coding skills to work generating images for the Web.

In this tutorial

This tutorial steps through using the GD library, showing you how to create and alter images on Web pages. It starts with the basic GD construct, then builds on it to showcase various graphics techniques.

The purpose of this tutorial is to show you how to get started with the GD library and to provide a variety of techniques you can apply to your Web-page coding. The tutorial doesn't cover every GD function, but it teaches you the basics. The Resources section provides Web sites where you can learn more about using the GD library.


Prerequisites

You're advised to do a refresher of PHP basic programming methods before you begin this tutorial. Knowledge of image and graphics processing is helpful. You should understand pixels, shapes, graphic file types, resizing, and similar graphics-manipulation concepts.

A working knowledge of PHP will go a long way in making this tutorial easy to follow. You should also have general programming knowledge. The particular syntax requirements, although similar to some other programming languages, may take some study.


System requirements

Web server
Any operating system and any Web server can be used. Feel free to use Apache V2.X, or the IBM® HTTP Server. Download from Apache or IBM.
PHP
PHP V5.1.4 or later is required.
GD
As of PHP V4.3, a version of the GD library comes bundled with new PHP installations. You won't need to worry about this requirement if you're using a later version. Use phpinfo() to see if your PHP installation is GD-enabled. The section "Introducing GD" discusses the history and versions of GD, and where to find the library.


Formats

html, pdf


Share this....

digg Digg this story del.icio.us del.icio.us Slashdot Slashdot it!


Back to top


Document options

Document options requiring JavaScript are not displayed


My developerWorks needs you!

Connect to your technical community