PHP images with dynamic text

Writing text on a PHP generated image:
//
//	(C)2011 Dag Jonny Nedrelid
//	Website: http://thronic.com
//
//	This file takes as a GET variable, returns it on a png image.
//

if (!isset($_GET['s']))
	exit;

$img = imagecreatetruecolor(50, 20);
$bg_color = imagecolorallocate($img, 255, 255, 255);
$text_color = imagecolorallocate($img, 0, 0, 0);
imagefill($img, 0, 0, $bg_color);
imagestring($img, 4, 5, 2,  $_GET['s'], $text_color);

// Return and show new image
header('Content-Type: image/png');
imagepng($img, NULL, 0);
imagedestroy($img);


This document was last updated July 9th, 2011.
Written by: Dag Jonny Nedrelid
©2007-2012 http://thronic.com


Feel free to leave a comment.
Name:
URL:
0