MyBB Community Forums

Full Version: [Tutorial] Text to Image
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This allows you to convert text to an image. This is useful if you want to sell/share your username (psn etc) on a forum without bots spamming it.


img.php
<?php
error_reporting(0);
// Set the content-type
header('Content-Type: image/png');

// Create the image
$im = imagecreatetruecolor(200, 15);

// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);

// The text to draw
$text = htmlspecialchars($_GET["value"]);
// Replace path by your own font path
$font = 'fixedsys.ttf';

// Add some shadow to the text
//imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);

// Add the text
imagettftext($im, 10, 0, 5, 10, $black, $font, $text);

// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>

Regular Expression:
\[e\](.*?)\[/e\]



Replacement:
<img src="img.php?value=$1" class="billz_img" />

Things you can change:
-img.php >eg file_name.php
-[e] >eg [hide]