Quantcast

Jump to content

» «
Photo

[Question][PHP] News image?

1 reply to this topic
Svip
  • Svip

    I eat babies

  • The Connection
  • Joined: 12 Nov 2001
  • None

#1

Posted 30 April 2005 - 08:11 PM

I have seen these pictures with people's post count in.

But I was wondering if it was possible to make a picture that showed the lastest news on a website ( which is mine ( so I know the tables ) )?

And how would I write such a PHP script?

I have never tried writting images in PHP. bored.gif

Jack_Knife
  • Jack_Knife

    we usually take all niggas garments

  • Leone Family Mafia
  • Joined: 08 Dec 2001

#2

Posted 01 May 2005 - 12:36 AM

CODE
<?

header("Content-type: image/png");

list(,$song) = explode("\n", file_get_contents("http://ws.audioscrobbler.com/txt/recent/Jack_Knife"));

$fontnum = 3;
$fontwidth = imagefontwidth($fontnum);
$fontheight = imagefontheight($fontnum);

$string = $song;

$img = imagecreate(strlen($string)*$fontwidth, $fontheight);

$white = imagecolorallocate($img, 0, 0, 0);
$black = imagecolorallocate($img, 255, 255, 255);

$trans = imagecolortransparent($img, $white);
imagefill($img, 0, 0, $white);

imagestring($img, $fontnum, 0, 0, $string, $black);

imagepng($img);
imagedestroy($img);

?>


That's the code for my 'now playing' image in my sig. To get the news from your site, you'd need to do a similar thing, just change the url in there, and parse the code to find the string you want within that.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users