Page 1 of 1

Quote Script

Posted: Fri May 21, 2004 11:18 am
by Thanatos`
I'm trying to make a script that reads a quote from a file, then overlays it onto an image. The script is a php file which acts as a png, located here. First, the file wasn't displaying as an image, but as text, but I seem to have fixed the image part, but now I'm getting an error on line 16.. here's the code

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);
?>
?>

Posted: Fri May 21, 2004 11:36 am
by launchcode
Line 16 being what?

Posted: Fri May 21, 2004 12:08 pm
by feyd
$rand((double) microtime() * 10000000);

uh.. yeah.. that'd be an error.

Posted: Fri May 21, 2004 12:23 pm
by launchcode
Heh.. yeah :)

Posted: Sat May 22, 2004 8:22 am
by Thanatos`
I was sort of hoping you'd reply telling me how to fix the error, not simply state that there was an error :P

Posted: Sat May 22, 2004 8:27 am
by launchcode
Well I've no idea what that $rand line is supposed to be doing :) It looks like it might be trying to seed the random number generator.. but, who knows. Comment it out.

Posted: Sat May 22, 2004 8:54 am
by Thanatos`
I followed the tutorial from Here. Turns out I'd used a $ instead of an S :P. The sig works, which is good, but the quotes aren't displaying now :(

Posted: Sat May 22, 2004 9:55 am
by litebearer
well a rough fix would be to create a 1 celled table, display the image as a background for the table/cell and then simply enter the quote as the cell contents. (kind of ridiculous but it would work)