square1 / resized-laravel
Laravel package for resized.co, the on-demand image manipulation service.
Installs: 75 755
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 9
Forks: 2
Open Issues: 0
Requires
- php: ~7.4|~8.0
- square1/resized: ~1.3.0
Requires (Dev)
- laravel/framework: ^8.12
- orchestra/testbench: ^6.6
- squizlabs/php_codesniffer: ~2.3
This package is auto-updated.
Last update: 2024-11-16 18:18:29 UTC
README
This is the Laravel package for resized.co, an on-demand image resize manipulation service.
Install
Via Composer
$ composer require square1/resized-laravel
Version 2 removed support for PHP7.1 - if you require it, run
$ composer require square1/resized-laravel:1.1
To use the Resized Service Provider, you must register the provider when bootstrapping your Laravel application.
Find the providers
key in your config/app.php
and register the Resized Service Provider.
'providers' => array( // ... Square1\Laravel\Resized\ResizedServiceProvider::class, )
Find the aliases
key in your config/app.php
and add the Resized facade alias.
'aliases' => array( // ... 'Resized' => Square1\Laravel\Resized\ResizedFacade::class, )
Configuration
By default, the package uses the following environment variables to auto-configure the plugin without modification:
RESIZED_KEY
RESIZED_SECRET
RESIZED_DEFAULT_IMAGE
Usage
Set the default failover image.
Resized::setDefaultImage('http://www.example.com/no-image.jpg');
Generate a 300x500 resized image URL.
$url = Resized::process('http://www.example.com/some-image-to-resize.jpg', '300', '500');
Generate an image URL that is contrained to 300 width whilst mantaining aspect ratio.
$url = Resized::process('http://www.example.com/some-image-to-resize.jpg', '300', '');
Generate an image URL that is contrained to 500 height whilst mantaining aspect ratio.
$url = Resized::process('http://www.example.com/some-image-to-resize.jpg', '', '500');
Override image slug.
$url = Resized::process('http://www.example.com/some-image-to-resize.jpg', '300', '500', 'A nice image name');
Specify the compression level through the options array.
Data ranging from 0 (poor quality, small file) to 100 (best quality, big file). Quality is only applied if you're encoding JPG format since PNG compression is lossless and does not affect image quality. Default: 90.
$url = Resized::process('http://www.example.com/some-image-to-resize.jpg', '', '500', 'A nice image name', ['quality' => 100]);
Testing
$ composer test
License
The MIT License (MIT). Please see License File for more information.