imagecreatefrompng(): '/home/ubuntu/dv8.png'不是有效的 PNG 文件
我的代码:
$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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我使用未以“索引”模式保存的 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.