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, JPEG, WBMP, and XPM. Even more convenient, PHP can output image streams directly to a browser. You need to install GD Library for this purpose. Simply you can do this.
If you have a LAMP (PHP. APACHE and Mysql) Installation in your System , you can install GD library using the following .
in Ubuntu /Debian Install the package
$ sudo apt-get install php5-gd ( or use synaptic for installing this package )
Now Restart Your apache
$sudo /etc/init.d/apache2 restart