Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 43,859 times

Contents

Downloads

Related Categories

Image Generation on the FLY using PHP - Getting Started

jdk

Getting Started

Note
To handle the code described in this article, you should feel comfortable with the PHP scripting language at an intermediate level. Also, if you haven't got the necessary libraries to generate images installed (explained in a minute), then you should be able to modify the php.ini file. In our example, we will be using PHP on a Windows 2000 machine running Apache.

To generate images in real-time using PHP, we need to have the GD library installed. To make sure you have the GD library installed, create a new PHP page named checkgd.php in a directory on your web server. Enter the following code into checkgd.php:

<?php
phpinfo(INFO_MODULES);
?>

Run the checkgd.php page on your web server. If you can find a section for the GD library (like in the sample shown below), then you have the GD library installed and ready to go:

On the other hand, if you don't see a section for the GD library, then you will need to download and install the GD library. If you are running windows, then installation instructions are available here. If you are running Linux, installation instructions are available here.

Both of the links to installation instructions shown above use an older version of the GD library. This is because with the newer versions, any support for GIF images has been removed due to copyright infringements.

As mentioned at the beginning of this article, we will be creating an image that contains a random number, similar to the methods used by yahoo.com and paypal.com when you register to become a member.

So, now that we have the GD library installed as part of our PHP distribution, let's jump right in and create our first image.

A fellow who believes in simple things, simple way.

Comments

  • dynamic image on the fly

    Posted by babulgogoi on 02 Apr 2005

    Hi

    I saw them using a image-on-the-fly script as (at www.worldspaceasia.com):
    Image Generation on the fly

    Posted by chukws on 06 Nov 2004

    Very good tutorial and useful. But am wondering, if it can be converted to be used as a counter in a website, to get the number of visitors to the site. It will then start from a certain number and co...

  • php_gd.dll

    Posted by altimastr on 03 Sep 2004

    after installing the gd.dll am i suppose to uncomment it in the php.ini file and if so do i restart my server to get it to load??? after putting it in my php.ini file and uncommenting it nothing came ...

  • Checking

    Posted by niceguy_reddy on 18 Aug 2004

    I used the script it was good. The random script is accessed as an image in another script, then how to access the number displayed on the image so that i can check that the user entered the correct d...

  • great tutorial, thanks

    Posted by Idea_Rat on 05 Aug 2004

    very well-written & useful javascript:smilie(':)')