imagecreatefrompng(): '/home/ubuntu/dv8.png'不是有效的 PNG 文件

发布于 2024-11-25 14:34:40 字数 547 浏览 4 评论 0原文

我的代码:

    $filepath = '/home/ubuntu/dv8.png';
    echo "mime content type: " .mime_content_type ($filepath) . "<br />";
    $image_src = imagecreatefrompng($filepath);
    print_r($image_src);

它输出:

mime content type: image/png
Warning: imagecreatefrompng(): '/home/ubuntu/dv8.png' is not a valid PNG file in /var/www/test.php on line 2

有什么想法为什么我会得到这个?这可能和我的 PHP 版本有关吗? 5.3.2

phpinfo() 和 GD 部分列出:

PNG Support enabled

感谢任何帮助。

My code:

    $filepath = '/home/ubuntu/dv8.png';
    echo "mime content type: " .mime_content_type ($filepath) . "<br />";
    $image_src = imagecreatefrompng($filepath);
    print_r($image_src);

It outputs:

mime content type: image/png
Warning: imagecreatefrompng(): '/home/ubuntu/dv8.png' is not a valid PNG file in /var/www/test.php on line 2

Any ideas why I would get this? Would it have to do with my PHP version possibly? 5.3.2

phpinfo() and under the GD section lists:

PNG Support enabled

Appreciate any help.

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

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

发布评论

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

评论(1

人间☆小暴躁 2024-12-02 14:34:40

当我使用未以“索引”模式保存的 PNG 文件时,我遇到的问题主要是透明度问题。

要将 PNG 从 RGB 模式更改为索引模式,请在 gimp 中打开它并转到
图像->模式->索引

并再次导出。看看是否能解决问题。

I get problems mainly with the transparency when i use a PNG file that is not saved in 'indexed' mode.

To change a PNG from RGB mode to indexed mode, open it in gimp and go to
IMAGE-> MODE-> INDEXED

and export it again. See if that fixes it.

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