MySpace

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

iamme

Lifer
Jul 21, 2001
21,058
3
0
Originally posted by: Kev
I like how LoKe says you guys are putting too much thought into it, then proceeds to serve up 40 lines of php code.

LOL, i was thinking the same thing...:laugh:
 

QED

Diamond Member
Dec 16, 2005
3,428
3
0
Originally posted by: austin316
Originally posted by: MathMan
Originally posted by: austin316

anyway to do this as text? or should I just save my quotes as .gifs?

or make an animated .gif?

Actually, you can use the GD lib with PHP to convert a text string into a graphic image on the fly.

It'd be pretty easy to write a PHP script which grabbed a line from a text file containing all of your quotes, and then create a gif file with that quote.


any pointers where I could find a guide to help me?



Ok... I went ahead and just merged two scripts I found that will do that job for you.

Take a look at the code here.

Place this file on your server-- with a php extension, of course. You will also need to place a true-type font file in the same directory (I used arial), as well as your quote file (called quotes.txt, with one quote per line). For best results, also make a subdirectory called "cache" which will store already-created quote images.

The end result can be seen right here.

Hope that helps...
 

austin316

Diamond Member
Dec 1, 2001
3,572
0
0
Originally posted by: MathMan
Originally posted by: austin316
Originally posted by: MathMan
Originally posted by: austin316

anyway to do this as text? or should I just save my quotes as .gifs?

or make an animated .gif?

Actually, you can use the GD lib with PHP to convert a text string into a graphic image on the fly.

It'd be pretty easy to write a PHP script which grabbed a line from a text file containing all of your quotes, and then create a gif file with that quote.


any pointers where I could find a guide to help me?



Ok... I went ahead and just merged two scripts I found that will do that job for you.

Take a look at the code here.

Place this file on your server-- with a php extension, of course. You will also need to place a true-type font file in the same directory (I used arial), as well as your quote file (called quotes.txt, with one quote per line). For best results, also make a subdirectory called "cache" which will store already-created quote images.

The end result can be seen right here.

Hope that helps...


awesome work. however, what code do I use to make these quotes appear in myspace?
 

purbeast0

No Lifer
Sep 13, 2001
53,637
6,521
126
Originally posted by: austin316
Originally posted by: MathMan
Originally posted by: austin316
Originally posted by: MathMan
Originally posted by: austin316

anyway to do this as text? or should I just save my quotes as .gifs?

or make an animated .gif?

Actually, you can use the GD lib with PHP to convert a text string into a graphic image on the fly.

It'd be pretty easy to write a PHP script which grabbed a line from a text file containing all of your quotes, and then create a gif file with that quote.


any pointers where I could find a guide to help me?



Ok... I went ahead and just merged two scripts I found that will do that job for you.

Take a look at the code here.

Place this file on your server-- with a php extension, of course. You will also need to place a true-type font file in the same directory (I used arial), as well as your quote file (called quotes.txt, with one quote per line). For best results, also make a subdirectory called "cache" which will store already-created quote images.

The end result can be seen right here.

Hope that helps...


awesome work. however, what code do I use to make these quotes appear in myspace?

lol dude you sound like the kids who come in here asking for programming help on some basic c++ stuff but they haven't even opened the book to attempt to learn anything on their own.
 

austin316

Diamond Member
Dec 1, 2001
3,572
0
0
Originally posted by: purbeast0
Originally posted by: austin316
Originally posted by: MathMan
Originally posted by: austin316
Originally posted by: MathMan
Originally posted by: austin316

anyway to do this as text? or should I just save my quotes as .gifs?

or make an animated .gif?

Actually, you can use the GD lib with PHP to convert a text string into a graphic image on the fly.

It'd be pretty easy to write a PHP script which grabbed a line from a text file containing all of your quotes, and then create a gif file with that quote.


any pointers where I could find a guide to help me?



Ok... I went ahead and just merged two scripts I found that will do that job for you.

Take a look at the code here.

Place this file on your server-- with a php extension, of course. You will also need to place a true-type font file in the same directory (I used arial), as well as your quote file (called quotes.txt, with one quote per line). For best results, also make a subdirectory called "cache" which will store already-created quote images.

The end result can be seen right here.

Hope that helps...


awesome work. however, what code do I use to make these quotes appear in myspace?

lol dude you sound like the kids who come in here asking for programming help on some basic c++ stuff but they haven't even opened the book to attempt to learn anything on their own.

I don't have a book on php nor do I care to learn. thanks for your help though.
 

QED

Diamond Member
Dec 16, 2005
3,428
3
0
well, to get this to work you will need your own webhost that has PHP support.

Put the quotes.php file there, you true-type font file, and your quotes.txt file there.

Once it's there, you just use the full URL for the quotes.php file on your server in your image tag.

For instance, to place my random quote generator in your myspace area, you would you the following HTML:

[ img src="http://www.castechint.com/quotes.php" ]

(replace the [] brackets with < and > )

 

austin316

Diamond Member
Dec 1, 2001
3,572
0
0
Originally posted by: MathMan
well, to get this to work you will need your own webhost that has PHP support.

Put the quotes.php file there, you true-type font file, and your quotes.txt file there.

Once it's there, you just use the full URL for the quotes.php file on your server in your image tag.

For instance, to place my random quote generator in your myspace area, you would you the following HTML:

[ img src="http://www.castechint.com/quotes.php" ]

(replace the [] brackets with < and > )


awesome. all done except for the true type font file. what is that?
 

QED

Diamond Member
Dec 16, 2005
3,428
3
0
It's a font file. You can find them in your Windows directory... usually C:\WINDOWS\FONTS

For the script above, I used Arial (with a filename of arial.ttf). If you choose a different font, change the name of the font file used in the quotes.php file.
 

wtfbbq

Senior member
Oct 17, 2005
213
0
0
works for me, but i wonder if there is a way to automatically insert breaks when making the picture? longer quotes create an extremely long picture.
 

austin316

Diamond Member
Dec 1, 2001
3,572
0
0
Originally posted by: wtfbbq
works for me, but i wonder if there is a way to automatically insert breaks when making the picture? longer quotes create an extremely long picture.

my link works for you? hmmm
 

QED

Diamond Member
Dec 16, 2005
3,428
3
0
Originally posted by: wtfbbq
works for me, but i wonder if there is a way to automatically insert breaks when making the picture? longer quotes create an extremely long picture.

There sure is...

Right after this line in the code:

$box = @ImageTTFBBox($font_size,0,$font_file,$text) ;

You can check the prospective width of the image by looking at the value of abs(box[2] - box[0]).

If it is above a certain width, then simply use your favorite word-wrapping algorithm to split it up into two or more seperate strings. Then alter the height of the created image to be abs(box[5] - $dip)) * $number_of_lines .

Now draw each of the new text strings onto the image independently.
 

QED

Diamond Member
Dec 16, 2005
3,428
3
0
Originally posted by: austin316
Originally posted by: wtfbbq
works for me, but i wonder if there is a way to automatically insert breaks when making the picture? longer quotes create an extremely long picture.

my link works for you? hmmm

I probably think he means that it works for him running off of his server.

I'm not sure why it isn't working for you... you might need to take a peek at your server log files and see if you're getting any strange error messages.

Also, try verifying the PHP is installed and working properly by writing a simple PHP script (called hello.php) with this single line:

<?php echo("hello world!"); ?>

And see if you get anything when you access it via its URL....