我正在尝试使用 GD 将(shoutcast 状态)脚本的以下输出写入图像,但它不起作用。我究竟做错了什么?
$string = "/home/test.txt";
使用上面的只是显示文件的路径而不是它的内容。
输出:
psytrance.value 37
breaks.value 8
dubstep.value 6
reggae.value 130
oldskool.value 5
ambient.value 81
test.value <- this should be ignored!
complete.value 267
php:
<?php
header ("Content-type: image/png");
$string = "/home/test.txt";
// try changing this as well
$font = 4;
$width = imagefontwidth($font) * strlen($string) ;
$height = imagefontheight($font) ;
$im = imagecreatefrompng("/home/banner2.png");
$x = imagesx($im) - $width ;
$y = imagesy($im) - $height;
$backgroundColor = imagecolorallocate ($im, 255, 255, 255);
$textColor = imagecolorallocate ($im, 0, 0,0);
imagestring ($im, $font, $x, $y, $string, $textColor);
imagepng($im);
?>