您好,我正在我的 laravel
项目中使用 glide ( http://glide.thephpleague.com/ ) 进行图像处理。
我在存储图像时遇到问题。
“调用未定义函数Intervention\Image\Gd\imagecreatefrompng()
”
奇怪的是,我可以在我的 Mac 上使用“预览”打开图像。但不是在浏览器中。 Photoshop 还告诉我这个文件有问题,它已损坏。
这是我将图像保存在私有(private)文件夹中的方法:
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 导致了问题。 我该如何解决这个问题?
最佳答案
这是因为缺少 GD 库
。试试这个:
您必须启用库 GD2。
找到您的(正确的)php.ini
文件
找到行:;extension=php_gd2.dll
并删除前面的分号。
该行应如下所示:
extension=php_gd2.dll
然后重新启动 apache,你就可以开始了。
关于php - Laravel 调用未定义函数 Intervention\Image\Gd\imagecreatefrompng(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39767067/