473,625 Members | 3,329 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Jul 16 '05 #1
0 1677

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

Similar topics

3
6064
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 it is not loading the new picture. Can any one help? public void Presentation_Load(object sender, System.EventArgs e)
4
2746
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. It should put a blue and yellow box on the page with "This is a test" as part of the picture. But what I get is a broken Gif. The other problem is that I can't view the source???? The view source is disabled for this page. What causes this?
10
3400
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 sequence. eg, pic1,pic2,pic3,pic4,pic5,pic6 to ==> pic3,pic2,pic6,pic1,pic5,pic4 below are part of my code Dim theImage(0 To 7) As Object Dim myArray(0 To 7) As Object
1
5591
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 working fine. My aim is to double click the picture box and the desired image will be drawn at the mouse position. This works fine unless I scroll or minimise the form because the image isnt repainted after movement. I looked up drawing the image to...
0
8256
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8189
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8694
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8635
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8497
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7184
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6118
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4089
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

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.