Home arrow PHP arrow Page 2 - Generating Images on the Fly With PHP

Generating Images on the Fly With PHP

For developers like Divyesh, one of the most popular features of PHP is real-time image generation. That is, we can create a new image canvas, "paint" it, and either save it to a file, or send it directly to the browser. In this article, Divyesh will show you how to create an image in real-time with PHP.

Author Info:
By: Divyesh Jariwala
Rating: 4 stars4 stars4 stars4 stars4 stars / 69
December 13, 2001
  1. · Generating Images on the Fly With PHP
  2. · The GD image library
  3. · Creating our image
  4. · Displaying our image
  5. · Generating the random number
  6. · Changing the font of our random number
  7. · Conclusion

print this article

Generating Images on the Fly With PHP - The GD image library
(Page 2 of 7 )

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:




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:

The details of a successfully installed GD library

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 at http://php.weblogs.com/php_gd. If you are running Linux, installation instructions are available at http://www.e-gineer.com/instructions/install-gd13-for-php-with-apache-on-linux.phtml.

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.
blog comments powered by Disqus

- Removing Singletons in PHP
- Singletons in PHP
- Implement Facebook Javascript SDK with PHP
- Making Usage Statistics in PHP
- Installing PHP under Windows: Further Config...
- File Version Management in PHP
- Statistical View of Data in a Clustered Bar ...
- Creating a Multi-File Upload Script in PHP
- Executing Microsoft SQL Server Stored Proced...
- Code 10x More Efficiently Using Data Access ...
- A Few Tips for Speeding Up PHP Code
- The Modular Web Page
- Quick E-Commerce with PHP and PayPal
- Regression Testing With JMeter
- Building an Iterator with PHP

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials