2010-09-07 29 views
1

是否有可能讓PHP GD庫輸出.ico文件?PHP GD圖標輸出

是否有與imagepng類似的功能?

+0

如果你這樣做爲favicon,作爲PNG輸出可能會工作正常=) – mkoistinen 2010-09-07 23:47:15

+0

SO已經涵蓋了這一點,看起來像:http://stackoverflow.com/questions/2628114/convert-png-file-to-ico-with-php – mkoistinen 2010-09-07 23:49:01

回答

2

你應該能夠做到這一點只需通過設置內容類型爲「圖像/ PNG」和圖標鏈接REF設置PHP腳本生成的圖標

$img = imagecreatetruecolor(16, 16); 
    $blue = imagecolorallocate($im, 100, 100, 255); 
    imagefill($im, 0, 0, $blue); 

    header('Content-type: image/png'); 
/* 
or if it needs to be the icon content type 
    header('Content-type: image/ico'); 
*/ 
    imagepng($im); 
    imagedestroy($im); 
0

爲什麼不使用netpbm的ppmtowinicon程序? GD - > file(xbm) - > file(ppm) - > file(ico) - > php stream,content-type = image/ico。

+3

請解釋... – 2010-09-08 00:35:58