Library tutorials & articles
Image Generation on the FLY using PHP
Getting Started
|
|
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.
Related articles
Related discussion
-
Sending Multiple ListBox Selection to PHP
by cnrez (6 replies)
-
A particular gallery image
by margy80 (0 replies)
-
code highlighting using jquery
by pjm (1 replies)
-
PHP London July Meetup
by Dalton (0 replies)
-
How to prevent spam
by boopathi_php (0 replies)
Related podcasts
-
EarthClassMail.com - Moving from LAMP to .NET 3.5
Scott chats with Matt Davis, architect at EarthClassMail.com, about their move from a LAMP stack (Linux/Apache/mysql/PHP) to .NET 3.5. What's working, what's not, and what kinds of issues are they running into as their architect their solution.
Events coming up
-
Jul
18
WordCamp UK 2009
Cardiff, United Kingdom
This is the second WordCamp UK - an informal annual gathering of WordPress publishers, designers and developers based in the United Kingdom.
Hi
I saw them using a image-on-the-fly script as (at www.worldspaceasia.com):
<a href="modules.php?name=Content&pa=listpagescategories&cid=2"><img src="includes/img.php?title=Western Classical/Jazz&textsize=8&border=1&imgype=randomTTF" border="0" alt="Western Classical/Jazz"></a>
The :
title=
imgype=randomTTF
are crucial!
So whts the secret of the img.php?
Regards
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 count sequencially upwards. It could start from 1 or 10.
Thanks
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 displayed number.
very well-written & useful javascript:smilie('
')
thanx 4 ur time!
thanx 4 ur time!
hi:
I copied your code to my PHP4.3.x+Windows2000Server+Apache2, The picture does not show at a browser, only white page. I checked the sapce befor the "<?php" carefully.
In fact, befor I have a similar bad experience that I can't show picture at my machine. But If I put the code to a linux machine , it works. The situation is all my other php codes, including session,mysql, work fine. Only for this method, header(header("Content-type:image/jpeg"), the send out a image, it does not work.
I guess there must be some setting parameters problem at apache2. Does anyone have any idea?
Thanks
I think your posting in the wrong place buddy! this is for creating and showing PHP images on-the-fly not VB! If you DO really want to take a PHP created image and put it in a VB form you can either post back here or email me at webmaster@isgeeky.com
To my knowledge it is not possible to send an image created on-the-fly using PHP without the content-type header being modified. Why do you not want to use the "Header("Content-Type: Image/jpg")" code?
Actually I have seen your image generation on the fly and i have used it on my project. But i facing a problem is i don't want to use a Header("Content-Type: Image/jpg") . So if you have link please send me on sshti123@hotmail.com.
Vivek
Actually I have seen your image generation on the fly and i have used it on my project. But i facing a problem is i do want to use a Header("Content-Type: Image/jpg") . So if you have link please send me on sshti123@hotmail.com.
Vivek
Actually I have seen your image generation f\on the fly and i have used it on my project. But i facing a problem is i do want to use a Header("Content-Type: Image/jpg") . So if you have link please send me on sshti123@hotmail.com.
Vivek
i want to display an image on a form when an item is selected from a ComboBox. the image will be stored on the a:\drive (floppy). there will be multiple items in the combobox, each 1 relating to a specific picture. i just need the basic code to get the img to appear after selecting the item from the combobox. if n e 1 could email me the code or tell me where to get it, that would be great! oz_utester@hotmail.com
thanx 4 ur time!
This thread is for discussions of Image Generation on the FLY using PHP.