Jump to content

GD Image Coding Help


Recommended Posts

OK, so I have my GD image which takes random text from a text file...But what I want to know is how can I code this so that when the image runs out of space, the remaining text can go to the next line?

This is my code right now:

<?php
Header ('Content-type: image/jpeg');
Header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
Header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
Header('Pragma: no-cache');

// create the image
$image = imagecreatefrompng
("http://www.astromike.com/gd_stuff/ip/pic.png");

// set the colours
$cool  = imagecolorallocate($image, 81, 86, 96);
$black = imagecolorallocate($image, 0, 0, 0);
$white = imagecolorallocate($image, 255, 255, 255);
$red   = imagecolorallocate($image, 255, 0, 0);
$grey  = imagecolorallocate($image, 204, 204, 204);
$green = imagecolorallocate($image, 206, 129, 18);
$blue  = imagecolorallocate($image, 0, 0, 255);

// set quote file
$quotes = file('quotes.txt');
$quote = array_rand($quotes);

// set the font and print text
$font = '/home/soaresm/public_html/gd_stuff/ip/font.ttf';

ImageTTFText ($image, 8, 0, 10, 17, $black, $font, "Your IP Address is ".$REMOTE_ADDR);
ImageTTFText ($image, 8, 0, 10, 34, $black, $font, "gamehead loves ".$name);
ImageTTFText ($image, 8, 0, 10, 51, $black, $font, $quotes[$quote]);

// output and destroy
imagepng($image);
imagedestroy($image);

?>

$quotes is the text file...

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...