【问题标题】:Command (GetRealPath) is not available for driver (Gd)命令 (GetRealPath) 不适用于驱动程序 (Gd)
【发布时间】:2018-06-17 15:42:50
【问题描述】:

我正在尝试创建上传图像的水印版本,并使用 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);

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

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

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

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

和

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

任何帮助将不胜感激

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

【问题讨论】:

  • 查看了 1,609 次,但没有人赞成,你帮了我很多忙。我支持你。

标签: php laravel intervention


【解决方案1】:

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

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

编辑后的图像现在可以正确保存,答案在这里找到:Laracasts

【讨论】:

  • 谢谢伙计,它解决了我的问题,我试图调整图像大小,然后将其存储在我的 FTP 服务器(文件系统磁盘(FTP))上。你的编码方法有帮助
猜你喜欢
  • 1970-01-01
  • 2021-02-13
  • 2011-05-11
  • 2018-04-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多