我試圖使用GD將(shoutcast status)腳本的以下輸出寫入圖像,但它不起作用。我究竟做錯了什麼?將(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);
?>
看起來你已經知道了答案 - *是*,前提是你可以獲得shoutcast狀態。 – LSerni 2013-02-20 21:44:06
我已經更新了我的問題以上... – 2013-02-20 22:51:31
啊,我明白了。對不起,我應該想通了......好吧,你可以接受@ take的答案;-) – LSerni 2013-02-20 23:38:51