简体   繁体   中英

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

I am facing some issues with GD in a laravel project. My phpinfo says that GD is enabled but I get an "undefined function Intervention\\Image\\Gd\\imagecreatefrompng()" error.

在此处输入图片说明

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. That should be listed along the GD section of your phpinfo() .

Which PHP version are you using?

From the documentation :

To enable support for png add --with-png-dir=DIR . Note, libpng requires the zlib library, therefore add --with-zlib-dir[=DIR] to your configure line. As of PHP 7.4.0, --with-png-dir and --with-zlib-dir have been removed. libpng and zlib are required .

There's a chance you need to install libpng and zlib on your system.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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