FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Text - Image





The-Master
I created a random text php script making a random text from a list show. But how would I go about making it an image that displays a random text.

http://www.dougie.frih.net/image.phps

http://www.dougie.frih.net/image.php
coreymanshack
by using the php image functions of course!
alkutob
coreymanshack wrote:
by using the php image functions of course!


Any more details please ?

thank you
hexkid
alkutob wrote:
Any more details please ?

http://www.frihost.com/forums/vp-433971.html#433971
PatTheGreat42
I once made something like this back when Chuck Norris was big stuff. It took a Chuck Norris fact from a website, broke it up so it would fit on the picture, then posted it on the picture. Here's the code (It doesn't quite work anymore because the guy changed his website, rendering my quote-grabbing code useless. Everything else is A-OK, though):
Code:
<?php
//Grab text from RSS feed.
$feed = "http://www.4q.cc/chuck/rss.php";
//if(is_readable($feed)) {}
$rss = file($feed);
$clean = trim(strip_tags($rss[13]));
//Backup facts.
if(strlen($clean) > 200 or $clean == "")
{
   $foo[] = "There once was a man from Nantucket. Chuck Norris paralyzed him from the waist down.";
   $foo[] = "Chuck Norris's communication with The Afterlife is made possible by talking to the black guy on Walker Texas Ranger.";
   $foo[] = "If you see Chuck Norris crying he will grant you a wish, if your wish is dying.";
   $foo[] = "If you make Chuck Norris stroke his beard in confusion, you're finished, because Norris doesn't understand confusion, only pain.";
   $foo[] = "The only reason World War II occured was because Chuck Norris was taking a nap.";
   $foo[] = "What's behind Chuck Norris' beard? Nothing. Just another fist.";
   $clean = $foo[rand(0,5)];
}
//Tidy it up.
foreach(explode(" ",$clean) as $blargh)
{
   $linelength = $linelength + 1 + strlen($blargh);
   if($linelength < 33)
   {$fact[$arraynum] = $fact[$arraynum]." ".$blargh;}
   else
   {
      $linelength = strlen($blargh) + 1;
      $arraynum++;
      $fact[$arraynum] = $fact[$arraynum]." ".$blargh;
   }
}
//Put it in the picture.
Header ("Content-type: image/png");
$img_handle = imageCreateFromPNG("chucknorris.png");
$color = ImageColorAllocate($img_handle,255,255,0); //RGB values.
//Font size, x-offset, and y-offset.  Font values 1-5.  1 smallest.
$yoffset = 5;
foreach($fact as $chuck)
{
   ImageString($img_handle,3,140,$yoffset,$chuck,$color);
   $yoffset+=15;
}
ImagePng($img_handle);
ImageDestroy($img_handle);
//Original Code:  http://www.icemelon.com/tutorials/9/Dynamic_Images.htm.
//This is some of the prettiest code I've ever done.
?>

Hope the example helps!
Related topics
Tools you use
Free Online Games (Do not make more new threads about this)
CSS layout help
Adsense lies
What are your Firefox extensions
Feedback Please
Google AdSense Question
I Need an Ultimate Paint Tutorial
Video Editing Tutorial needed. Paying 800 Fri$
Layout is all messed up when viewed via IE.
how many adsense units allow?
old styles?
ANDYS ART
The adsense Links.
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.