Web Hosting

PHP Hosting

Zend Hosting

Sablotron Hosting

ImageMagick Hosting

Forum Hosting

PHPNuke Hosting

PHPBB Hosting

Order Now


New to hosting?
Check out the step-by-step guides to help you get started.
Setting up your 1st website
Transferring your website

Domain Search: www.

SERVERS & NETWORK  |  SUPPORT  |  WHY OXXUS  |  TESTIMONIALS  |  ABOUT US  |  CONTACT |  ORDER NOW

 

 

PHP GD Library Tutorial

 

 

GD is an open source code library for the dynamic creation of images.

 

GD is used for creating PNG, JPEG and GIF images and is commonly used to generate charts, graphics, thumbnails on the fly.

 

While not restricted to use on the web, the most common applications of GD involve web site development.

 

The GB library was originally developped by Thomas Boutell and is now maintained by Pierre-A. Joye under the umbrella of PHP.net

 

Requirements

Using gd requires an ANSI C compiler. All popular Windows 95 and NT C compilers are ANSI C compliant.

 

Any full-ANSI-standard C compiler should do. Most Unix/Linux OS based systems has the gcc which is ANSI compliant.

 

As of version 1.6, the zlib compression library  and the libpng library are required.

 

As of version 1.6.2, text using anti aliased TrueType fonts can be drawn if the libttf library is installed, but this is not mandatory.

 

Zlib is available for almost every platform from the zlib web site. Libpng is available for a variety of platforms from the PNG web site.

 

A PNG viewer is also required and is supported through almost every web browser that currently exists.

 

The GD library can be added to the php installation if the php services are compiled besides the bundle package offered within the apache installation and therefore any additional installation won't be required and will be available within the php itself.

 

In order to find out if the installed PHP services provides the GD library support the php info page should be created with the code below.

The file phpinfo.php with the contents stated below and access the url for example http://www.test.com/phpinfo.php

 

<?php
phpinfo();
?>

 

Using GD libraries within the PHP

 

<?php
header("Content-type: image/png");
$string = $_GET['text'];
$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);

?>

 

This example would be called from a page with a tag like:

<imgsrc="button.php?text=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.

 

For detailed explanations and more examples the http://www.php.net/image would be the right place to start.

 

(c) Copyright 2003 Oxxus PHP Hosting Services. All rights reserved 


Order with confidence
100% Secure Ordering
Privacy Policy
Money back guarantee


...........................................

 

PHP Tutorials:

What is PHP?

PHP Installation

Using PHP & Cookie

PHP Code Example

GD Library

Connecting MySQL & PHP

Zend Overview

ImageMagick Overview

Using Sablotron XSLT

 

Copyright ® 2003-2007 Oxxus.Net * USA * UK * AUP * Best web hosting solutions from internets leading web hosting provider * Tutorials * Resources * Blog * FAQ