Convert String to Image
In facebook.com we see a nice thing,that is when u try to edit ur profile the e-mail address becomes image ! I mean u just type string and that becomes image.Here is the code which can convert string into image.
$date = ‘Raquibul Islam’;
$img = imagecreatetruecolor(100,25);
$bgcol = imagecolorallocate($img,255,255,255);
$hatcol = imagecolorallocate($img,rand(128,255),rand(128,255),rand(128,255));
$headcol = imagecolorallocate($img,255,225,205);
$bodycol = imagecolorallocate($img,0,0,0);
$eyecol = imagecolorallocate($img,rand(100,200),rand(0,128),rand(128,255));
$mouthcol = imagecolorallocate($img,rand(128,255),0,0);
imagefill($img,0,0,$bgcol);
imagestring($img,2,8,4,$date,$bodycol);
imagesetthickness($img,1);
imagerectangle($img,0,0,99,24,$bodycol);
header(“Content-type: image/png”);
imagepng($img);
imagedestroy($img);
Just copy the code and paste it into a .php file and run it.The string from $data will represent as an image.











I’ve tried that but there was problem with ‘Call to udefined function …..’
And there shows a Syntax Error on Line 2.
Whts may be the problem in my script or config?
@Nuhil
When ever u just copy and paste the code from blog please take a close look to the quote .
Thanks …. it’s working.
But could you tell me how to convert a textfile into image… when i try to include a file in it give the error in image.
hey
thanx for the subject
can you please tell me how to increase the string size so it appears in large font?
thank u
Owh……….THank You Very Much….. Akhirnya DaPet Juga Scriptnya~
I want to convert Hindi txt stored in database to image , how can I do it?
it not working
u need the GD lib for this.