PHP GD 图标输出

发布于 2024-09-18 11:41:14 字数 358 浏览 4 评论 0原文

是否可以拥有 PHP GD 库输出 .ico 文件?

有没有类似 imagepng 的功能?

Is it possible to have the PHP GD library output a .ico file?

Is there a function similar to imagepng?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

倾`听者〃 2024-09-25 11:41:14

您应该能够简单地通过将内容类型设置为“image/png”并将图标链接引用设置为生成图标的 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);

you should be able to do it simply by setting the content type to 'image/png' and setting the the icon link ref to the php script that generates the icon

    $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);
梦亿 2024-09-25 11:41:14

为什么不使用netpbm的ppmtowinicon程序? GD->文件(xbm)->文件(ppm) ->文件(ico)-> php 流,内容类型 = image/ico.

Why not to use netpbm's ppmtowinicon program? GD -> file(xbm) -> file(ppm) -> file(ico) -> php stream, content-type = image/ico.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文