A Laravel package for WebP image conversion and optimization.
composer require yassineas/laravel-webp
Publish the configuration file:
php artisan vendor:publish --provider="YassineAS\LaravelWebp\Providers\WebpServiceProvider"
use YassineAS\LaravelWebp\Facades\Webp;
// Convert image to WebP
$webpPath = Webp::convert('/path/to/image.jpg');
// Convert with quality setting
$webpPath = Webp::convert('/path/to/image.jpg', 80);
// Convert and resize
$webpPath = Webp::convert('/path/to/image.jpg', 80, 800, 600);
# Convert single image
php artisan webp:convert /path/to/image.jpg
# Convert all images in directory
php artisan webp:convert-directory /path/to/images/