Download the PHP package bvtterfly/lio without Composer
On this page you can find all versions of the php package bvtterfly/lio. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bvtterfly/lio
More information about bvtterfly/lio
Files in bvtterfly/lio
Package lio
Short Description Easily optimize images using Laravel
License MIT
Homepage https://github.com/bvtterfly/lio
Informations about the package lio
🚨 THIS PACKAGE HAS BEEN ABANDONED 🚨
I no longer use Laravel and cannot justify the time needed to maintain this package. That's why I have chosen to abandon it. Feel free to fork my code and maintain your own copy.
Easily optimize images using Laravel
Lio can optimize PNGs, JPGs, SVGs, and GIFs by running them through a chain of various image optimization tools.
This package is heavily based on Spatie
's spatie/image-optimizer
and spatie/laravel-image-optimizer
packages and can optimize local images like them.
In addition, It optimizes images stored on the Laravel filesystem disks.
Here's how you can use it:
If you don't like facades, just resolve a configured instance of Bvtterfly\Lio\OptimizerChain
out of the container:
Installation
You can install the package via composer:
The package will automatically register itself.
The package uses a bunch of binaries to optimize images. To learn which ones on how to install them, head over to the image optimization tools section.
The package comes with some sane defaults to optimize images. You can modify that configuration by publishing the config file.
This is the contents of the published config file:
Command-Line Optimization tools
The package will use these optimizers if they are present on your system:
Here's how to install all the optimizers on Ubuntu:
And here's how to install the binaries on MacOS (using Homebrew):
And here's how to install the binaries on Fedora/RHEL/CentOS:
If You can't install and use above optimizers, You can still optimize your images using reSmush Optimizer.
Which tools will do what?
The package will automatically decide which tools to use on a particular image.
JPGs
JPGs will be made smaller by running them through JpegOptim. These options are used:
-m85
: this will store the image with 85% quality. This setting seems to satisfy Google's Pagespeed compression rules--strip-all
: this strips out all text information such as comments and EXIF data--all-progressive
: this will make sure the resulting image is a progressive one, meaning it can be downloaded using multiple passes of progressively higher details.
PNGs
PNGs will be made smaller by running them through two tools. The first one is Pngquant 2, a lossy PNG compressor. We set no extra options, their defaults are used. After that we run the image through a second one: Optipng. These options are used:
-i0
: this will result in a non-interlaced, progressive scanned image-o2
: this set the optimization level to two (multiple IDAT compression trials)
SVGs
SVGs will be minified by SVGO 2. SVGO's default configuration will be used, with the omission of the cleanupIDs
plugin because that one is known to cause troubles when displaying multiple optimized SVGs on one page.
Please be aware that SVGO can break your svg. You'll find more info on that in this excellent blogpost by Sara Soueidan.
The default SVGO optimizer (Svgo2
) is only compatible with SVGO 2.x
. For custom SVGO configuration, you must create your configuration file and pass its path to the config array:
If you installed SVGO 1.x
and can't upgrade to 2.x
, You can uncomment the Svgo
optimizer in the config file:
GIFs
GIFs will be optimized by Gifsicle. These options will be used:
-O3
: this sets the optimization level to Gifsicle's maximum, which produces the slowest but best results
WEBPs
WEBPs will be optimized by Cwebp. These options will be used:
-m 6
for the slowest compression method in order to get the best compression.-pass 10
for maximizing the amount of analysis pass.-mt
multithreading for some speed improvements.-q 90
Quality factor that brings the least noticeable changes.
(Settings are original taken from here)
Set Binary Path
If your binaries are not accessible in the global environment, You can set them using binaries_path
option in the config file.
reSmush Optimizer
When you can't install command-line optimizer tools, you can comment them on the config file to disable them and uncomment the reSumsh optimizer to enable it. reSmush provides a free API for optimizing images. However, it can only optimize up to 5MB of PNG, JPG, GIF, BMP, and TIF images.
Usage
You can resolve a configured instance of Bvtterfly\Lio\OptimizerChain
out of the container:
or using facade:
if your files are local you can using optimizeLocal
method:
Using the middleware
If you want to optimize all uploaded images in requests to route automatically, You can use the OptimizeUploadedImages
middleware.
Writing a custom optimizers
You may want to write your own optimizer to optimize your images via other utilities. An optimizer is any class that implements the Bvtterfly\Lio\Contracts\Optimizer
interface:
If you want to view an example implementation take a look at the existing optimizers shipped with this package.
You can add the fully qualified classname of your optimizer as a key in the optimizers
array in the config file.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
- ARI
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of lio with dependencies
ext-fileinfo Version *
guzzlehttp/guzzle Version ^7.4
illuminate/contracts Version ^9.0
spatie/laravel-package-tools Version ^1.9.2
spatie/temporary-directory Version ^2.0