[英]GD LIbrary on a Mac: "undefined function Intervention\Image\Gd\imagecreatefrompng()"
I am facing some issues with GD in a laravel project.我在 laravel 项目中遇到了 GD 的一些问题。 My phpinfo says that GD is enabled but I get an "undefined function Intervention\\Image\\Gd\\imagecreatefrompng()" error.
我的 phpinfo 说 GD 已启用,但出现“未定义函数 Intervention\\Image\\Gd\\imagecreatefrompng()”错误。
I am facong the issues when I try to execute this:当我尝试执行此操作时,我遇到了问题:
public function update(Request $request, $id)
{
//Show the image
echo '<img src="'.$_POST['img_val'].'" />';
//Get the base-64 string from data
$filteredData=substr($_POST['img_val'], strpos($_POST['img_val'], ",")+1);
//Decode the string
$unencodedData=base64_decode($filteredData);
//Save the image
$storagepath = storage_path('app/images/users/' . Auth::user()->id);
$imgoutput = File::put($storagepath.'/flyer2.png', $unencodedData);
return view('backend.flyers.index')->withImgoutput($imgoutput);
//->withStoragepath($storagepath);
}
It looks like your GD installation doesn't have support for PNG images.看起来您的 GD 安装不支持 PNG 图像。 That should be listed along the GD section of your
phpinfo()
.这应该列在
phpinfo()
的 GD 部分。
Which PHP version are you using?您使用的是哪个 PHP 版本?
From the documentation :从文档:
To enable support for png add
--with-png-dir=DIR
.要启用对 png 的支持,请添加
--with-png-dir=DIR
。 Note, libpng requires the zlib library, therefore add--with-zlib-dir[=DIR]
to your configure line.请注意,libpng 需要 zlib 库,因此将
--with-zlib-dir[=DIR]
到您的配置行。 As of PHP 7.4.0,--with-png-dir
and--with-zlib-dir
have been removed.从 PHP 7.4.0 开始,--
--with-png-dir
和--with-zlib-dir
已被删除。 libpng and zlib are required .libpng 和 zlib 是必需的。
There's a chance you need to install libpng
and zlib
on your system.您可能需要在系统上安装
libpng
和zlib
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.