Php 命令(GetRealPath)不可用于驱动程序(Gd)

Php 命令(GetRealPath)不可用于驱动程序(Gd),php,laravel,intervention,Php,Laravel,Intervention,我正在尝试创建一个上传图像的水印版本,并使用laravel 5.6和干预将它们存储到存储文件夹中 //create the watermarked image $watermarkedImage = Image::make($request->file('photo')); $watermark = Image::make(Storage::get('watermark.png')); $watermark->widen(floor(($waterma

我正在尝试创建一个上传图像的水印版本,并使用laravel 5.6和干预将它们存储到存储文件夹中

    //create the watermarked image
    $watermarkedImage = Image::make($request->file('photo'));
    $watermark = Image::make(Storage::get('watermark.png'));
    $watermark->widen(floor(($watermarkedImage->width() / 4) * 3));
    $watermarkedImage->insert($watermark, 'center');

    //save the watermarked and standard image to disc and recording their names for db
    $location = $request->file('photo')->store('public/uploads');
    $fileName = md5($location . microtime());
    $extension = '.' . explode("/", $watermarkedImage->mime())[1];
    $watermarkedLocation = Storage::putFileAs('public/watermarked/', $watermarkedImage, $fileName . $extension);
每当我尝试运行此代码时,都会出现以下错误:

命令(GetRealPath)不可用于驱动程序(Gd)

我也尝试过对watermardImage变量使用->save()和->store()命令,但他们发现了错误:

无法将图像数据写入路径(public/watermarked/6b2492b7856c4d68ea15509c5b908a8c.png)

命令(存储)不可用于驱动程序(Gd)

任何帮助都将不胜感激


编辑:忘记添加它成功地保存了没有水印的原始图像

我最终找到了一个修复方法,而不是像我使用put那样使用store或putfile:

Storage::put('public/watermarked/' . $fileName . $extension, $watermarkedImage->encode());

编辑后的图像现在可以正确保存,答案如下:

查看了1609次,但没有向上投票,你帮了我的忙,可能还有更多。我投你一票。