Laravel image intervention compression Laravel image intervention compression laravel laravel

Laravel image intervention compression


Try the encode() method, where you can specify the format and the quality (for jpg). So, everytime you use the cache, try to do this:

$cache_image = Image::cache(function ($image) use ($size, $name) {    $image        ->make(...)        ->...        // any other call to image manipulation methods        ->encode('jpg', 75);    // ...    return $image;});


You need to use the save() method of the Image class where you will specify the quality of the image. The actual signature of the method save() is:

save([string $path, [int $quality], [string $format]])

Sample Examples are as follows:

<br>// open an image file<br>$img = Image::make('public/foo.jpg');<br><br>// save file as jpg with medium quality<br>$img->save('public/bar.jpg', 60); <br><br>// save the same file as jpg with default quality<br>$img->save('public/baz.jpg');<br><br>// save the file in png format with good quality<br>$img->save('public/bar.png', 75);<br><br>// save the image jpg format defined by third parameter<br>$img->save('public/foo', 80, 'jpg');<br><br>

For more information, please take a look at http://image.intervention.io/api/save