Given that we made the image 20 wider and taller than the text, using 10 now as the offset centers the text in the image. The numbers are x-coordinate of the upper left corner of the text string and y-coordinate of the upper left corner of the text string. The imagestring() function types our text into the image. The minus ones in some of the arguments keep the function from trying to draw outside of the edge of the image. The argument numbers are X1 Y1 X2 Y2, which is saying to draw a line from X1,Y1 to X2,Y2. The imageline() function is used to draw a border around the image. Then we use the imagefill() function to fill the image with one of the colors. The numbers in the argument are RGB color numbers. Next we use imagecolorallocate() to allocate colors for the image. Next we use imagecreatetruecolor() to create a new true color image of the needed size. The adding of 20 is to give the final image padding so the words are not jammed against the image edge. Variables are defined using the imagefontwidth() and imagefontheight() functions from the GD library. Once the text gets to the image-gif.php script, the script GETs it into the PHP variable $mytext. Note that the text gets sent via URL query string in the variable "mytext". When it does this page refresh, it POSTs the text to an image-gif.php image creation file. The mytext-convert-to-gif-image.php script is mostly an HTML input form and the form action is to run this same file, mytext-convert-to-gif-image.php. What the 2 scripts below do is turn your typed text input and turn it into an actual GIF image (as long as you have the correct permissions to do this-ask your host). Imagegif() function from the GD library is needed-along with several other functions-for this image creation to work. It usually is, but if it is not, get your host to do so. The PHP Script for Writing GIF Image Filesįirst, notice that we are counting on the GD library to have been enabled in your PHP installation.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |