This is a discussion on Write text on an existing PNG image in PHP within the PHP Programming forums, part of the Web Development category; Hi, How to Write text on an existing PNG image in PHP Regards, sivaraman...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| hi, this will explain you you write text in PNG image <? // load the image from the file specified: $im = imagecreatefrompng("image.png"); // if there's an error, stop processing the page: if(!$im) { die(""); } // define some colours to use with the image $yellow = imagecolorallocate($im, 255, 255, 0); $black = imagecolorallocate($im, 0, 0, 0); // get the width and the height of the image $width = imagesx($im); $height = imagesy($im); // draw a black rectangle across the bottom, say, 20 pixels of the image: imagefilledrectangle($im, 0, ($height-20) , $width, $height, $black); // now we want to write in the centre of the rectangle: $font = 4; // store the int ID of the system font we're using in $font $text = "vdhri.net"; // store the text we're going to write in $text // calculate the left position of the text: $leftTextPos = ( $width - imagefontwidth($font)*strlen($text) )/2; // finally, write the string: imagestring($im, $font, $leftTextPos, $height-18, $text, $yellow); // output the image // tell the browser what we're sending it Header('Content-type: image/png'); // output the image as a png imagepng($im); // tidy up imagedestroy($im); ?>
__________________ With, J. Jeyaseelan Everything Possible |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How do I check that text entered in a text form field is an integer? | itbarota | HTML, CSS and Javascript Coding Techniques | 2 | 10-26-2007 12:25 AM |
| How to Encode a text and Decode it to get the original text using c# .Net? | Archer | C# Programming | 1 | 07-21-2007 01:10 AM |
| What’s the difference between Response.Write() andResponse.Output.Write()? | prasath | ASP and ASP.NET Programming | 1 | 07-19-2007 03:56 AM |
| How to convert a word document/text document/PDF file into an image file? | kingmaker | C# Programming | 0 | 07-16-2007 11:23 PM |
| Append to an existing array? | muthukumar | PHP Programming | 1 | 07-12-2007 11:23 PM |