Creating Dynamic images with PHP - Printable Version +- Support Forums (https://www.supportforums.net) +-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87) +--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18) +---- Forum: PHP The Hypertext Preprocessor (https://www.supportforums.net/forumdisplay.php?fid=21) +---- Thread: Creating Dynamic images with PHP (/showthread.php?tid=302) Pages:
1
2
|
Creating Dynamic images with PHP - Gaijin - 10-05-2009 Welcome and enjoy! Intro: Since I don't have enough Posts to update my signature, I've decided to show you how to create dynamic signature with PHP Demo Wrote: Requirements:
Functions: Let us start writing our PHP file. I've named mine image.php, you can name yours different. We start first with defining the width and height of the image. PHP Code: $width = 450; Now we use the function imagecreate() to create our image. PHP Code: $image = imagecreate($width, $height); 1st = width of the image, 2nd = height of the image. Next we will define Background color for the image. PHP Code: $background = imagecolorallocate($image, 87, 87, 87); 1st = image resource that was create with the imagecreate() function. 2nd/3rd/4th are the RGB color value paramter Now that we have the basic of our image let us add some text to it. PHP Code: $text = "I hope this will not get new Hackforums"; The function imagestring() accept 6 parameters. 1st = image resource that was create with imagecreate() 2nd = the font size 3rd = Left - distance from the left side of the image wich I've set to 10 pixel 4th = Top - distance from the top side of the image wich is also 10 pixel 5th = Text to add 6th = text color And the last step is to define our content as image. PHP Code: header ("Content-type: image/png"); imagepng() is then used to output given resource. imagepng() accept 4 parameters 1st = image resource that was created with imagecreate() 2nd = This one is optional and is used to set the path and file name of the image - value must be string 3rd = Is also optional and it is used to define image compression quality from 0 = none - to 9 = Best 4th = filters - allows reducing the image size Read More: GD Docs imagedestroy() imagecreatetruecolor() imagegif() imageellipse() Source (Click to View) Thank you for reading! RE: Creating Dynamic images with PHP - Elektrisk - 10-05-2009 Thank you for posting this tutorial. RE: Creating Dynamic images with PHP - Gaijin - 10-05-2009 Thanks.... I'm in love with GD.... RE: Creating Dynamic images with PHP - Omniscient - 10-07-2009 Awesome tutorial. I feel like adding awards to the site just for you. RE: Creating Dynamic images with PHP - Gaijin - 10-07-2009 (10-07-2009, 07:06 PM)Omniscient Wrote: Awesome tutorial. I feel like adding awards to the site just for you. Thank you very much Omni. And if please include the Ninja award.. RE: Creating Dynamic images with PHP - MAcar - 10-07-2009 Thanks for this tut very helpful! RE: Creating Dynamic images with PHP - Gaijin - 10-07-2009 Thank you too! I'm glad I could help. RE: Creating Dynamic images with PHP - Moudi - 10-08-2009 I always wondered how they do that ip creepy stuff >_> RE: Creating Dynamic images with PHP - Gaijin - 10-08-2009 (10-08-2009, 01:02 PM)Moudi Wrote: I always wondered how they do that ip creepy stuff >_> Yes this is the way just add $_SERVER['SERVER_ADDR'] to the text you want to have on the image. RE: Creating Dynamic images with PHP - Headshot - 10-08-2009 Whoa, thanks for sharing. |