Freek Van der Herten: Optimize images in Laravel apps
In a continuation of his previous post about an image optimization package for PHP Freek Van der Herten covers some refactoring and advancements they've made to the package to make it even easier to use.
A while ago we released image-optimizer. In short this package can make all kinds of images smaller by stripping out metadata and applying a little bit of compression. Read this blogpost to learn more about it. Although it’s pretty easy to work with the package, we felt that we could deliver a more seamless experience in Laravel apps. That’s why we created our newly released laravel-image-optimizer package.
The package uses a bunch of binaries to optimize images. To learn which ones and how to install them, head over to the optimization tools section in the readme of the underlying image-optimizer package. That readme also contains info on <a href="https://github.com/spatie/image-optimizer#which-tools-will-do-what>what these tools will do to your images.
He then includes some code examples putting this new version of the package to work with a Laravel-based application. The examples include replacing the image with an optimized one, saving the optimized one to a new path and resize all images in a request. There's also an example configuration included showing the options you can set to customize your site's image optimization even more.