小编Con*_*ker的帖子

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

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

    //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);
Run Code Online (Sandbox Code Playgroud)

每当我尝试运行此代码时,我都会收到错误:

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

我还尝试在 watermardImage 变量上使用 ->save() 和 ->store() 命令,但出现了错误:

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

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

任何帮助将不胜感激

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

php laravel intervention

8
推荐指数
1
解决办法
1万
查看次数

标签 统计

intervention ×1

laravel ×1

php ×1