Optimization of images is done by the underlying spatie/image-optimizer. It assumes that there are a few optimization tools, such as JpegOptim an Pngquant present on your system. For more info, check out the relevant docs.
To shave off some kilobytes of the images the package can optimize images by calling the
Here’s the original image of New York used in all examples has a size of 622 Kb. Let’s optimize it.
Image::load('example.jpg') ->optimize() ->save('example-optimized.jpg');
The size of the optimized image is 573 Kb.
No matter where or how many times you call
optimize in you chain, it will always be performed as the last operation once.
To optimization of images is done by the underlying spatie/image-optimizer package. You can pass your own customized chains as array. The keys should be fully qualified class names of optimizers and the values the options that they should get. Here’s an example
Image::load('example.jpg') ->optimize([Jpegoptim::class => [ '--all-progressive', ]]) ->save();