PHP Code:
<?
// Set content type header
header("Content-type: image/png");
// Constants
$charWidth = 7;
$charWidthDisp = 6;
$charHeight = 10;
$chars = array("." => 11, ":" => 12, "(" => 13, ")" => 14, "-" => 15, "'" => 16, "!" => 17,
"_" => 18, "+" => 19, "\\" => 20, "/" => 21, "[" => 22, "]" => 23, "^" => 24,
"&" => 25, "%" => 26, "," => 27, "=" => 28, "$" => 29, "#" => 30);
// Variables
$username = "R3D"; // Change this to your Audioscrobbler username
// Retrieve name of last song played and format
list(,$song) = explode("\n", @file_get_contents("http://ws.audioscrobbler.com/txt/recent/".$username));
if (!isset($song) || strlen($song) == 0) {
$song = "Not playing anything";
**
$song = strtoupper($song);
if (strlen($song) > 41) $song = substr($song, 0, 38)."...";
// Load the background image and set transparency
$image = imagecreatefrompng("background.png");
$green = imagecolorallocate($image, 0, 255, 0);
$trans = imagecolortransparent($image, $green);
// Load the font image
$fontImage = imagecreatefrompng("font.png");
// Loop through string printing a character at a time
$startX = 80;
$startY = 6;
for ($i=0; $i<strlen($song); $i++) {
$char = $song[$i];
$asc = ord($char);
switch ($asc) {
case ($asc >= 65 && $asc <= 90): // Letters
imagecopy($image, $fontImage, $startX + $i * $charWidthDisp, $startY, ($asc - 65) * $charWidth, 0, $charWidth, $charHeight);
break;
case ($asc >= 48 && $asc <= 57): // Numbers
imagecopy($image, $fontImage, $startX + $i * $charWidthDisp, $startY, ($asc - 48) * $charWidth, $charHeight, $charWidth, $charHeight);
break;
case 34: // "
imagecopy($image, $fontImage, $startX + $i * $charWidthDisp, $startY, 26 * $charWidth, 0, $charWidth, $charHeight);
break;
case 64: // @
imagecopy($image, $fontImage, $startX + $i * $charWidthDisp, $startY, 27 * $charWidth, 0, $charWidth, $charHeight);
break;
default: // All other characters
if (isset($chars[$char])) imagecopy($image, $fontImage, $startX + $i * $charWidthDisp, $startY, $chars[$char] * $charWidth, $charHeight, $charWidth, $charHeight);
break;
**
**
// Output image and clean up
imagepng($image);
imagedestroy($image);
?>
The image here must be 300x40