PHP Text to Image

Change the settings and the click Create

Text The text to display
Rotation 0=normal 90=sideways
Font Size Points
Font
Padding Space around the image
Transparent  
Fore Colour R G B (0-255)
Back Colour R G B (0-255)
(pop-up window)  

Description

This script is a means to convert a string of text into an image. This has some simple uses such as displaying text such as email address that cannot be programmatically found. This can help to reduce the possibility of your email address being picked up by web crawlers and used for junk mail.

How To Use

To use the example interface above, simply modify or insert the string of text. You can edit any of the other settings, but this is optional.

Further Uses and Ideas:

How it Works:

The PHP Script

contact us for more information

Further Help

For anyone finding problems using this...

(1) Please test this example to ensure imagecreate works on your server...

<?php
header("Content-type: image/png");
$im = @imagecreate(110, 20)
    or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 0, 0, 0);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5,  "A Simple Text String", $text_color);
imagepng($im);
imagedestroy($im);
?>

(2) Make sure to use the example at the top of this page by sending POST variables from your form. For example msg,font,size ...

Relevant Links

Comments For This Page

Really amazing, Could you add a background image to the code to upload in the test ? That would be even more amazing!
On 6th September 2019
Demo is working fine, but can you provide solution for marathi text that means i copied text from google input tool. eg. %u0935%u0921%u093F%u0932%u093E%u0902%u091A%u093E %u0928%u094B%u0915%u0930%u0940 %u0935%u094D%u092F%u0935%u0938%u093E%u092F
By Anil Choudhari on 24th May 2019
how to get utf-8 unicode text to image??
On 9th March 2017
Wow, was looking for this. My previous test produced black background when rotated but this one works! big thanks!
By diko on 25th November 2016
Not support persian!
By Mohammad Mahdi Naderi on 8th July 2016
Works Fine for me but this not complete code for axample - text-shadow, opacity, align, background-color & etc.
By sunil on 10th August 2015
hi..how can i add height based on content description? .. moreover your ex code is not working
By gaja on 13th April 2015
hey this was awsm solution to my problem. but i m trying some changes in this. i m replacing simple text (hello) with HTML text(hello).
any one have any idea how to implement this
By Parveen Kumar on 23rd May 2014
Hi Jeff, we don't want hot-links to the site and wont be able to guarantee they will always work.
By Daft Logic on 25th April 2014
Very cool. Any way to create a unique url for the output so I can just link to the image on the fly instead of downloading/uploading the new image every time?
By Jeff on 24th April 2014
converte html para png ???
On 27th February 2014
Thank you so much. i tried by my self. but it is not work correct. :)
On 6th August 2013
Thanks for this class! TIP: The text rendering from GD is ugly, not antialiased. One way to make it look much better is to simply render text at 2x the size you want, then set a height on the <img> tag that is 50% of that (shrinking it back down to the size you really want to display). In Chrome, firefox and recent IE, you'll get a nice, antialiased image of text.
By Jonathan Cross on 2012-11-16
By Jonathan Cross on 16th November 2012
the small example code is working but the big code is not working...can anybody help plz?
By pankaj on 4th June 2012
good one
On 5th May 2012
Can you give me full example code?
By Raisul on 29th April 2012
thank you indeed, I've taken just the example part to build a basic captcha system.
By Luca on 4th April 2012
Duh people!!!

Replace the

header("Content-type: image/png");

with this:

$i = new textPNG;
$i->msg = "Your text here!!!";
header("Content-type: image/png");
$i->draw();

And you have a perfect script.
By GodPleaseGiveGreekPoliticiansB on 21st February 2012
text quality is bad
By ali on 29th November 2011
Not support utf-8 character ! :(
By GaRic on 13th November 2011
how can i add background image??
By florin on 2nd November 2011
The script is working fine for me. How can we merge image icons along with the text? eg: Heart Shape, Cross shape
"Dummy Text %u2665 "
By Prashant on 18th October 2011
Please how to enable the final font will be displayed somewhere at the same page as this application?
By hi on 16th August 2011
The text looks very poor quality. Is there some anti-aliasing effect you could put on it?

Could you also add multi-line with justification alignment.
By Leon on 15th August 2011
thanx gonna use, but haven't tested yet.
By whattimein.com on 19th July 2011
how to work this code in php plz explain...
I create image in text
By sk on 17th June 2011
php code not get in this site
By sk on 17th June 2011
Change the form so the input comes from a textarea instead of from an input element. :D I put in text with line breaks, it was only 3 lines long but, the script put out the expected result. :D

Nice. :D
By Matthew Kastor-Inare III on 3rd June 2011
great coding.. thank you
By san india on 1st June 2011
nice and thx
By @lek on 14th April 2011

30 out of 50 comments shown. See all comments.

Add your own comment below and let others know what you think: