kwaadpepper/image-resizer is a Laravel package for resize images on the fly and cache them.
It currently has 5 GitHub stars and 7.716 downloads on Packagist (latest version 4.0.1).
Install it with composer require kwaadpepper/image-resizer.
Discover more Laravel packages by kwaadpepper
or browse all Laravel packages to compare alternatives.
Last updated
Resizes an image on the fly and returns the new link
Via Composer
composer require kwaadpepper/image-resizer
1 - Publish config
php artisan vendor:publish --provider="Kwaadpepper\ImageResizer\ImageResizerServiceProvider"
2 - Set a config in templates array (config/image-resizer.php)
/**
* resize => will resize the image (boolean)
* fit => Combine cropping and resizing to format image in a smart way (boolean)
* keepRatio => will keep image ratio wile resizing (boolean)
* trim => boolean to trim the image using border color
* inCanvas => to make sure image boundarie is respected
* format => select tha wantd ouput form, yan can just convert images if you want
*/
'templates' => [
'smallWebp' => [
'height' => 500,
'width' => 250,
'inCanvas' => true,
'format' => 'webp',
'trim' => ['transparent', null, 10]
]
]
3 - type in console php artisan storage:link
4 - in your blade template override an image link
<img src="{{ asset(resize('images/volaillesfr_landing.png', 'smallWebp')) }}" alt="My resized image">
5 - Optional You can manually clean outdated cache files using command php artisan image-resizer:clean-cache
or force cleaning the cache using php artisan cache:clear
lifetime in config/image-resizer.php). Cached images are regenerated on demand.Please see the changelog for more information on what has changed recently.
composer test
Please see contributing.md for details and a todolist.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
MIT. Please see the license file for more information.