How to re-size an image in laravel?

0

This is the function that I have that saves the image everything works fine, but I want to know how I can do to resize the images and fill the images to not distort, like adding a margin, either vertically or horizontally according to as necessary to resize the image without distorting it.

public function store(CreateproductoRequest $request)
    {
            $input = $request->all();



        if($request->file('imagen_producto'))
    {       $path = Storage::disk('public')->put('image',$request->file('imagen_producto'));
            $input['imagen_producto'] = $path;
    }

                $producto = $this->productoRepository->create($input);
                Flash::success('Producto saved successfully.');
                return redirect(route('producto.index'));
    }

Install Intervention Image

The code stayed like this:

    image = $request->file('imagen_producto');
    $image_resize = Image::make($image->getRealPath())->resize(300,300);


    $path = Storage::disk('public')->put('image',$image_resize->file('imagen_producto'));

$input['imagen_producto'] = $path;

Now I miss this error

NotSupportedException in AbstractDriver.php line 117:
Command (File) is not available for driver (Gd).
    
asked by Neftalí García 25.09.2018 в 13:16
source

1 answer

0

There are many tools for image manipulation, recently use this library is very intuitive and easy to use.

Intervention Image and what you are looking for is here

I hope it's of your use.

Greetings!

    
answered by 25.09.2018 в 18:23