By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,304 Members | 1,254 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,304 IT Pros & Developers. It's quick & easy.

Random Quote in Picture

P: n/a
Hello,

I have a problem here, i'm try'n to make a static picture with in it a
random quote.
so far i have found a script that can make a pictrure from a quote, but i
want the quote oppon the picture

here's the script so far...
<?php

include('frases.php'); // Include the file with the
array of quotes
$total_frases = count($frase); // Count the quotes
$total_frases -- ; // -1 cause the index start with
zero
$rand_num = rand(0, $total_frases); // Sort a number from zero to
the total of quote
$mytext = $frase[$rand_num]; // $mytext have the sorted quote
$mytext = ltrim($mytext); // ltrim clean white lines
$mytext = ereg_replace("\r\n","\n",$mytext);// Clean the windows line breaks
(cr/lf) for simple unix style
$returns = explode("\n", $mytext); // Break the quote line by line
$num_linhas = count($returns); // Count the lines
$imwidth = 450; // Size of the picture
// The size of the picture are incremented by the number of
// lines. Each line have 13 pixel so this number is added yo
// any new line The +3 In the end is just to give a little
// stetic space
$imheight = (13*$num_linhas+3);

// Headers no cache and file header
header("Cache-Control: no-cache, must-revalidate");
header("Content-type: image/Png");
// Image Creation
$im = @ImageCreate ($imwidth, $imheight) or die ("Problems! Maybe you dont
have GD");
$background_color = ImageColorAllocate ($im, 255, 255, 255); // White, but
you can change it too

// COLOR OPTIONS
$white = ImageColorAllocate ($im, 255, 255, 255);
$black = ImageColorAllocate ($im, 60, 60, 60);
$red = ImageColorAllocate ($im, 255, 0, 0);
$blue = ImageColorAllocate ($im, 0,102,153);
$yellow = ImageColorAllocate ($im, 255,255,0);
$green = ImageColorAllocate ($im, 0,128,0);

// COLOR CONFIG
$text_color = $black; // Text Color
$sig_color = $red; // Signature Color (Last line)
$border_color = $black; // Border Color

$position = 1; // Space for the text not be displayed sticky in the border

// Insert the lines
$i = 0;
while($i < $num_linhas)
{
if (($i == $num_linhas-1) && ($num_linhas>1))
{
$text_color = $sig_color;
}

ImageRectangle($im, 0, 0, $imwidth-1, $imheight-1, $border_color); //
Draw border
ImageString($im ,3, 4, $position, $returns[$i], $text_color); //
Insert text
$position = $position + 13; //
Jump 13 pixels to the next line
$i++ ; //
Increment
}

ImagePng($im); // Create image
ImageDestroy; // Destroy image to clean up memory
?>

Jul 16 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.