TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-05-2008, 09:57 PM   #1 (permalink)
The Visitor
 
Join Date: Jan 2008
Posts: 3
Thanks: 0
Alex.Prisoner is on a distinguished road
Smile Simple GD Code For Text With A Background Image.

I have created a code to make it a background image with text in GD

Hope you enjoy

PHP Code:
<?
// CODE CREATED BY ALEX.PRISONER (HTTP://MYWORLDNESS.COM) [ALEX.TUNBRIDGE@HOTMAIL.COM] //
header ("Content-type: image/png");
$image = "/* Background image for your text here MUST BE PNG. */";
$im = imagecreatefrompng($image);
$font = "arial.ttf";
$text = $_GET['text']; //To add text to this image put yourpage.php?text= Text you want to display here.
$white = imagecolorallocate($im, 255, 255, 255); //If you know RBG you can change this but if you don't you might mess with the code :P
imagettftext($im, 20, 0, 20, 23, $white, $font, $text);
imagepng($im);
imagedestroy($im);
?>
Alex.Prisoner is offline  
Reply With Quote
Old 01-05-2008, 10:27 PM   #2 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,267
Thanks: 90
Wildhoney is on a distinguished road
Default

It's always nice to have a play around with GD from time-to-time, isn't? Just a note to anybody who's using your code. You have to drag the arial.ttf font from your fonts folder to your web-root (or just link to the font file in the font folder). Also ensure that your $_GET variable text is set. Finally, ensure the background image is a PNG. You're then good to go!

Thanks for sharing! Maybe the next thing you can do is detect what file type the background is, such as JPG, GIF, et cetera...
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 01:36 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design