473,385 Members | 1,901 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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",$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
0 1663

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: VenuGopal | last post by:
hi, i have a WELCOME screen. here i have a PICTURE BOX. there are 8 pictures that go into this Picture Box. At every 5 seconds i want to RANDOMLY load a new Picture. this is what i am using but...
4
by: tshad | last post by:
I am trying to set up an Image authorization where you type in the value that is in a picture to log on to our site. I found a program that is supposed to do it, but it doesn't seem to work. ...
10
by: lifity | last post by:
hi, i am stuck on part of my project and very new to VB. i had cut my picture into 6 equals part but need to display them randomly, without repeating the same part of the pic again, in random...
1
by: martinsmith160 | last post by:
Hi all I am trying to create a level builder tool for a final year project and im having some problems drawing. I have placed a picture box within a panel so i can scroll around the image which is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.