Laravel调用未定义的函数Intervention \ Image \ Gd \ imagecreatefrompng()

问题描述 投票:1回答:1

嗨我在我的http://glide.thephpleague.com/项目中使用滑行(laravel)进行图像处理。我在存储图像时遇到问题。 “调用未定义的函数Intervention\Image\Gd\imagecreatefrompng()

奇怪的是,我可以在我的Mac上用“预览”打开图像。但不是在浏览器中。 Photoshop也告诉我这个文件有问题,它已经损坏了。

这是我将图像保存在私人文件夹中的方式:

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.'/flyer.jpg', $unencodedData);

  return view('backend.flyers.index')->withImgoutput($imgoutput);
                                     //->withStoragepath($storagepath);

}

好像File :: put(XXX.jpg)JPG会导致问题。我怎样才能解决这个问题?

php laravel intervention php-glide
1个回答
1
投票

这是因为缺少GD Library。试试这个:

您必须启用库GD2。

找到你的(适当的)php.ini文件

找到行:;extension=php_gd2.dll并删除前面的分号。

该行应如下所示:

extension=php_gd2.dll

然后重启apache你应该好好去。

© www.soinside.com 2019 - 2024. All rights reserved.