text image maker

Started on the old forum in April 2009 · view the original in the archive · old links redirect here

4 replies · 785 views · started 17 years ago · 1 min read

2 participants
ori Lead · 512 posts #1

heres a lil script i made a few weeks ago it lets u create images from text in url theres a few parameters which are

color=COLOR size=FONT SIZE text=TEXT

also $font_file replace wif the font u want you'll most likely have to upload the font file for it to work

an example of using this code is (%20 is a space in url) color=FF0000&size=40&text=this%20is%20a%20test%20image

<?php
header("Content-type: image/gif");
//img.php
$hex_color = $_GET['color']?$_GET['color']:"000000";
$r_txt = hexdec(substr($hex_color,0,2)); 
$g_txt = hexdec(substr($hex_color,2,2)); 
$b_txt = hexdec(substr($hex_color,4,2));
$_GET['size'] = $_GET['size']?$_GET['size']:30;
$_GET['text'] = $_GET['text']?$_GET['text']:"You have not specified any text!!";
$size = imagettfbbox($_GET['size'],0,"$font_file",$_GET['text']);
$xsize = abs($size[0]) + abs($size[2]);
$ysize = abs($size[5]) + abs($size[1]);
$image = imagecreate($xsize,$ysize);
$bg = imagecolorallocate($image,$r_txt,$g_txt,$b_txt);
$color = ImageColorAllocate($image,$r_txt,$g_txt,$b_txt);
imagettftext($image,$_GET['size'],0,abs($size[0]),abs($size[5]),$color,"$font_file",$_GET['text']);
imagecolortransparent($image,$bg);
imagegif($image);
imagedestroy($image);
?>
ori Lead · 512 posts #3

there few scripts like this but they all got so much code this 1 nice an easy makes integration a piece of cake

ori Lead · 512 posts #4

by the way i used a ttf font file to do it so if the font is say arial.ttf jus put arial as the name dnt put .ttf

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close