gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 23:15:52 27 4
gpt4 key购买 nike

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

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

Command (GetRealPath) is not available for driver (Gd)



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

Can't write image data to path (public/watermarked/6b2492b7856c4d68ea15509c5b908a8c.png)





Command (Store) is not available for driver (Gd)



任何帮助将不胜感激

编辑:忘了补充,它成功地保存了没有水印的原始图像

最佳答案

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

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

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

关于php - 命令 (GetRealPath) 不适用于驱动程序 (Gd),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50898149/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com