abdelhamiderrahmouni/image-optimizer-command

A package that offers a command for image optimization using spatie/image-optimizer under the hood.

v0.1.2 2024-02-07 20:04 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A package that offers a command for image optimization using spatie/image-optimizer under the hood.

Pre-requisites

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/Debian:

sudo apt-get install jpegoptim
sudo apt-get install optipng
sudo apt-get install pngquant
sudo npm install -g svgo
sudo apt-get install gifsicle
sudo apt-get install webp
sudo apt-get install libavif-bin # minimum 0.9.3

And here's how to install the binaries on MacOS (using Homebrew):

brew install jpegoptim
brew install optipng
brew install pngquant
npm install -g svgo
brew install gifsicle
brew install webp
brew install libavif

And here's how to install the binaries on Fedora/RHEL/CentOS:

sudo dnf install epel-release
sudo dnf install jpegoptim
sudo dnf install optipng
sudo dnf install pngquant
sudo npm install -g svgo
sudo dnf install gifsicle
sudo dnf install libwebp-tools
sudo dnf install libavif-tools

Installation

I recommend you use this package in local environment only, even if it is possible to use it in production environment, it is not recommended to use it in production.

You can install the package via composer:

composer require abdelhamiderrahmouni/image-optimizer-command --dev

You can publish the config file with:

php artisan vendor:publish --tag="image-optimizer-command-config"

This is the contents of the published config file:

return [
    /*
     * The path to the assets folder. Default is public/assets.
     */
    'assets_path' => 'public/assets',
];

Usage

    php artisan images:compress [path/to/assets]

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.