Jump to content

[SOLVED] imagestring() Doesn't Draw String


Altec

Recommended Posts

I'm trying to write out a simple string onto an image. This is my code:

<?php

/**
* @author Steven
* @copyright 2009
*/

header('Content-Type: image/png');

/*if((file_exists('cache.png')) && (time() - filemtime('cache.png') <= 120)) {
    readfile('cache.png');    
    exit;
}*/

$remotefile = '[url=http://ws.audioscrobbler.com/1.0/user/StevenFX/recenttracks.xml%27;]http://ws.audioscrobbler.com/1.0/user/StevenFX/recenttracks.xml';[/url]
$localfile = 'StevenFX.xml';
if((!file_exists($localfile)) || (time() - filemtime($localfile) > 120)) {
    $contents = file_get_contents($remotefile);
    $fp = fopen($localfile, "w");
    fwrite($fp, $contents);
    fclose($fp);
}
$xml = @simplexml_load_file($localfile);

$src = imagecreatefrompng('[url=http://www.l33tsig.net/sig/1/Tagged.png%27]http://www.l33tsig.net/sig/1/Tagged.png'[/url]);
$dest = imagecreatefrompng('./3.png');

imagealphablending($dest, false);
imagesavealpha($dest, true);

imagecopymerge($dest, $src, 62, 0, 0, 0, 400, 100, 80);

$color = imagecolorallocate($dest, 255, 255, 255);
$string = 'Last track played: '.$xml->track[0]->name.' by '.$xml->track[0]->artist;
imagestring($dest, 1, 62, 130, $string, $color);

imagepng($dest, 'cache.png');
readfile('cache.png');
imagedestroy($dest);
imagedestroy($src);

?>

 

Everything but imagestring() (line 36) works. I can't figure it out. :P

 

EDIT: This is what the script does: http://www.phreakyourgeek.com/sig/3.php

 

Link to comment
https://forums.phpfreaks.com/topic/158353-solved-imagestring-doesnt-draw-string/
Share on other sites

$remotefile = '[url=http://ws.audioscrobbler.com/1.0/user/StevenFX/recenttracks.xml%27;]http://ws.audioscrobbler.com/1.0/user/StevenFX/recenttracks.xml';[/url]

 

$src = imagecreatefrompng('[url=http://www.l33tsig.net/sig/1/Tagged.png%27]http://www.l33tsig.net/sig/1/Tagged.png'[/url]);

 

 

Don't suppose [/url] not being inside the brackets has anything to do with it?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.