2010-09-07 49 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