A simple cache library and image formatting in PHP
- Requirements
- Supported image libraries
- Installation
- How to use
- Configuration parameters
- Methods
- Dependencies
- PHP >=5.4
- Fileinfo Extension
- GD Library (>=2.0)
- Imagick PHP extension (>=6.5.7)
Execute the following command to get the latest version of the package:
composer require devel8/laravel-image-filter
In your config/app.php
add Devel8\LaravelImageFilter\ImageFilterProvider::class
to the end of the providers
array:
'providers' => [
...
Devel8\LaravelImageFilter\ImageFilterProvider::class,
],
If Lumen
$app->register(Devel8\LaravelImageFilter\ImageFilterProvider::class);
Publish Configuration
php artisan vendor:publish --provider "Devel8\LaravelImageFilter\ImageFilterProvider"
$imageFilteredUrl = $imageManager->resolve( '/source/image/path/file.jpg', 'image_small' );
Parameter | Type | Value | Description |
---|---|---|---|
path.source | String | Path where the original image is stored | |
path.cache | String | Path where the image is stored with the filter applied | |
image.driver | String | gd o imagick | Driver that manipulates the images |
cache.path | String | Path where the files of cache manager will be stored | |
cache.ttl | Integer | Life time of the cache in minutes. By default the cache does not have ttl therefore it will never expire. | |
filters | Array | Filtration parameters | Set the filters with the formats that are applied to the images |
Parámetro | Tipo | Valor | Descripción |
---|---|---|---|
width | Integer | Image width | |
height | Integer | Image height | |
type | String | Filter types | Type of filter for the image |
Tipo | Descripción |
---|---|
resize | Change the size of the current image according to a width and height |
crop | Crop a part of the current image with width and height |
fit | Combine cropping and resizing to format the image in an intelligent way. You will automatically find the most suitable aspect ratio of your width and height determined in the current image, cutting out and changing its size to the given dimension. |
Returns the path of the image with the filter applied.
Parameter | Description |
---|---|
path | Path of the original image that you want to apply the filter |
filter | Nombre del filtro que se le ha indicado en el parámetro de configuración filters |
$imageFilteredUrl = $imageManager->resolve( '/source/image/path/file.jpg', 'image_small' );