繁体   English   中英

Mac 上的 GD 库:“未定义函数 Intervention\\Image\\Gd\\imagecreatefrompng()”

[英]GD LIbrary on a Mac: "undefined function Intervention\Image\Gd\imagecreatefrompng()"

我在 laravel 项目中遇到了 GD 的一些问题。 我的 phpinfo 说 GD 已启用,但出现“未定义函数 Intervention\\Image\\Gd\\imagecreatefrompng()”错误。

在此处输入图片说明

当我尝试执行此操作时,我遇到了问题:

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);

}

看起来您的 GD 安装不支持 PNG 图像。 这应该列在phpinfo()的 GD 部分。

您使用的是哪个 PHP 版本?

文档

要启用对 png 的支持,请添加--with-png-dir=DIR 请注意,libpng 需要 zlib 库,因此将--with-zlib-dir[=DIR]到您的配置行。 从 PHP 7.4.0 开始,-- --with-png-dir--with-zlib-dir已被删除。 libpng 和 zlib 是必需的

您可能需要在系统上安装libpngzlib

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM