Code: Select all
<?php
header('Content-type: image/x-png');
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
header('Expires: Thu, 19 Nov 2099 08:52:00 GMT');
header('Pragma: no-cache');
//define the font settings
$font_file = $_SERVER[DOCUMENT_ROOT]."/sig/CRILLEE.TTF";
$font_size = 10;
$y_start = 58;
$angle = 0;
$max_width = 360;
//read a quote from the text file
$quote_array = file("sig.txt");
$rand((double) microtime() * 10000000);
$quote = $quote_array[array_rand($quote_array)];
//calc horizontal starting point
$line_width = imagettfbbox($font_size, $angle, $font_file, $quote_array[$quote]);
$x_start = (($max_width - $line_width[2] - $line_width[0]) / 2) + 12;
//create the image
//header("Content-type: image/png")
$image = imagecreatefrompng("background.png");
$red = imagecolorallocate($image, 245, 245, 245);
//write the text to the image
imagettftext($image, $font_size, $angle, $x_start, $y_start, $red, $font_file, $quote_array[$quote]);
// Create and then destroy the image
imagepng($image);
imagedestroy($image);
?>