/    Sign up×
Community /Pin to ProfileBookmark

Image Text Generator

I was wondering how complex it is to create a script which generators which works like this:

[url]http://habbotimes.de/img/fonts/habbofont.php?text=hello&font=29[/url]

Basically, it collects images and creates one GIF image out of them (for example, A.gif, B.gif and C.gif all become one). Look at the form:

[url]http://www.habbotimes.de/index.php?s=63[/url]

Would anyone be kind enough to point me in the right direction or even go as far as creating this for me? Thank you.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@s_b37Oct 13.2007 — It is quite complicated, because you need to specify the sizes in px of each letter, and this would probably be done through a database, which has the source and pixel width of each letter

The php manual for creating images can be found at: http://www.php.net/image.

Basically, you'll need the ImageColorAllocate, ImageCreateFromGif, ImageCopy, and ImageGif functions, but you may also need to configure your server (needs GD or something enabled).

If you get the size and source data from the database, in the form:
[code=php]$imageInfo = array(
'a' => array(width, source),
...
)[/code]


for both uppercase and lowercase (and all symbols you'll need), and store your message in $message

then this should work:
[code=php]
// the space between each letter
$spacing = 10;
// we need total width when creating image
// set the current width, to the starting space
$width=$spacing;
for ($char=0; $char<strlen($message); $char++){
// adds the width
$width += $imageInfo[$message[$char]][0];
// add a spacing
$width += $spacing;
}

// replace 15 with height based on images
$img = ImageCreate($width, 15);
// set background white, pass image reference and r,g,b values
ImageColorAllocate($img, 255, 255, 255);

$xPos = 0;
for ($char=0; $char<strlen($message); $char++){
$src = $imageInfo[$message[$char]][1];
$ltrWidth = $imageInfo[$message[$char]][0];
$letter = ImageCreateFromGif($src);
// param order: base image, letter image, x pos in base, y pos in base, x pos in letter, y pos in letter, letter width (to copy), letter height (adjust to same as above)
ImageCopy($img, $letter, $xPos, 0, 0, 0, $ltrWidth, 15);
$xPos += $ltrWidth + $spacing;
}

// send the image header, you probably want a gif or a png
header ("Content-type: image/gif");
ImageGif($img);
ImageDestroy($img);[/code]


Note: not tested, and code is just rough idea
Copy linkTweet thisAlerts:
@HybrideauthorOct 13.2007 — Thanks for that. I'll see what I can do from there on.
×

Success!

Help @Hybride spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...