Facebook
Banner
XMPP JavaScript Library READ MORE

Creating dynamic rectangle image in php

PHP, Sachin Puri, 2009-08-23 19:42:11

To create dynamic images in PHP we make use of GD Library. GD Library contains many functions to create and manipulate images.


For this to work make sure that you compile your PHP with GD Library. If you are using PHP on windows system then follow these steps.


1.    Open php.ini file and search for "extension=php_gd2.dll"
2.    Uncomment it by removing semicolon (;) from beginning of line.
3.    Save it and close it.
4.    Open ext (extension) directory it should be in folder where you installed PHP.
5.    Make sure a file named “php_gd2.dll” exists; otherwise download it from PHP site.
6.    Now restart you web server (IIS, Apache etc.)
7.    Create a file named rectangle.php and copy paste code given below:

Now run this script in web browser, you will see three rectangles


black = which is image area like a canvas
blue and red = which are rectangles created by user.

If you have any doubt please post comment, I  will surely reply.


Have Fun!!!

Code:
Note: If you want to include this image in your web page then write this code in you web page <img src="rectangle.php"/>. In same way you can create other shapes also like ARC,Ellipse,Polygon, etc.
Add Your Comment
   
    Yes! I want to receive all comments by email

No Comments Posted Yet. Be the first one to post comment