Random Quote in Picture

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Maurits Veldhuyzen van Zanten

    Random Quote in Picture

    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",$myte xt);// 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_col or = ImageColorAlloc ate ($im, 255, 255, 255); // White, but
    you can change it too

    // COLOR OPTIONS
    $white = ImageColorAlloc ate ($im, 255, 255, 255);
    $black = ImageColorAlloc ate ($im, 60, 60, 60);
    $red = ImageColorAlloc ate ($im, 255, 0, 0);
    $blue = ImageColorAlloc ate ($im, 0,102,153);
    $yellow = ImageColorAlloc ate ($im, 255,255,0);
    $green = ImageColorAlloc ate ($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


    ?>



Working...