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

本小妞迷上赌 提交于 2019-12-31 03:29:27

问题


I am trying to create a watermarked version of an uploaded image and store both of them to the storage folder using laravel 5.6 and 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);

Whenever I try to run this code I get the error:

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

I've also tried using the ->save() and ->store() command on the watermardImage variable but they came up with the error:

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

and

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

Any help will be appreciated

Edit: Forgot to add that it successfuly saves the original image without the watermark


回答1:


I eventually found a fix, instead of using store or putfileas I used put:

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

The edited image now saves properly, answer found here: Laracasts



来源:https://stackoverflow.com/questions/50898149/command-getrealpath-is-not-available-for-driver-gd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!