Jump to content

Dynamic Signatures


Liam Morgan

Recommended Posts


you have an image create php code. it puts text over a specified image. this is one of mine that shows which itunes song is playing.

<?php

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

// create the image
$nameofimage = "now-playing.jpg"; //name of image
$image = imagecreatefromjpeg($nameofimage);

// set the colours
$cool = imagecolorallocate($image, 87, 87, 87);
$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 iTunes file (or other information)
$fname = "CurrentSong.txt";
$songfile = fopen($fname, "r");
$artist = fgets($songfile);
if($artist != " ") {
$songname = fgets($songfile);
$song = "Playing: $songname by $artist";
}
else
$song = "No music is playing";
fclose($songfile);

// set the font
$font = '/font.ttf';

// put it all together
//puts text on the image, see bellow about variables
ImageTTFText ($image, 8, 0, 9, 20, $white, $font, $song);


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

?>

imageTTFText

completed script example

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