【发布时间】: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