Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Writing text as an image
#1
[Image: YzwzC.png]

Using this can help leechers from getting info off your site.

Code:
header("Content-type: image/png");


// image size
$picture = imagecreate(500,200);


// background color

$gray = ImageColorAllocate ($picture, 51, 51, 51);


// white text color

$white = ImageColorAllocate($picture, 255, 255, 255);


//red text color

$red= ImageColorAllocate($picture, 255, 0, 0);


// green text color

$green = ImageColorAllocate($picture, 0, 255, 0);


// messages

$messages = array("this color will be red" => $red, "this will be green" => $green, "this will be white." => $white, "red." => $red, "red." => $red, "green" => $green, "white" => $white);


multilineTextToImage($picture, $messages, 2, 45, 30, 20);
ImagePng ($picture);

function multilineTextToImage($image, $string, $font_size, $x, $y, $yDis)  {
    $i = 0;
    foreach($string as $k=>$v)
     ImageString($image, $font_size, $x, $y + $yDis * $i++, $k, $v);
}
Credits to some php site for the most of it. i just made it multi-line and multicolored
Reply
#2
Nice thread alabama, I did make a thread similar to this awhile ago, but looks better with our banner on the top. Smile

Just thought I'd bump this up as it's truly a great, and useful snippet.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)