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

Not support persian!
By Mohammad Mahdi Naderi on 08/07/2016
Works Fine for me but this not complete code for axample - text-shadow, opacity, align, background-color & etc.
By sunil on 10/08/2015
hi..how can i add height based on content description? .. moreover your ex code is not working
By gaja on 13/04/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 23/05/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 25/04/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 24/04/2014
converte html para png ???
On 27/02/2014
Thank you so much. i tried by my self. but it is not work correct. :)
On 06/08/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 16/11/2012
the small example code is working but the big code is not working...can anybody help plz?
By pankaj on 04/06/2012
good one
On 05/05/2012
Can you give me full example code?
By Raisul on 29/04/2012
thank you indeed, I've taken just the example part to build a basic captcha system.
By Luca on 04/04/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 21/02/2012
text quality is bad
By ali on 29/11/2011
Not support utf-8 character ! :(
By GaRic on 13/11/2011
how can i add background image??
By florin on 02/11/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 18/10/2011
Please how to enable the final font will be displayed somewhere at the same page as this application?
By hi on 16/08/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 15/08/2011
thanx gonna use, but haven't tested yet.
By whattimein.com on 19/07/2011
how to work this code in php plz explain... I create image in text
By sk on 17/06/2011
php code not get in this site
By sk on 17/06/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 03/06/2011
great coding.. thank you
By san india on 01/06/2011
nice and thx
By @lek on 14/04/2011
gud
By gud on 07/04/2011
OMG great script! worked 100% from the beginning. Changed the font, etc. Thanks a lot!
On 07/04/2011
Demo is broken. Leaves little to no hope for the script.
On 11/02/2011
is it possible to generate a multi lines text image ??
By lamouchi on 26/01/2011

30 out of 46 comments shown. See all comments.

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

Share This Page

Share this page with others using one of the methods below. Telling others about Daft Logic is good and we appreciate your support!