A
A
an5432019-03-10 07:02:40
Laravel
an543, 2019-03-10 07:02:40

How to save multiple images in different sizes in Laravel?

Tell me how best to save pictures in different sizes, for example, 200x200, 800x800, 100,100
To save, I use this code, how to optimize it?

$filename  = 'img' . '.'200x200'.'.jpg';
    $resizedImage = Image::make($image);
    $resizedImage ->resize(800,800,function($img){$img->aspectRatio();});
    $resizedImage ->response('jpg');
    Storage::put('uploads/' . $filename,  $resizedImage);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Wells, 2019-03-10
@an543

Move it to a method and call it three times? What, exactly, is the problem?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question