Package Data | |
---|---|
Maintainer Username: | tarunmangukiya |
Maintainer Contact: | tarunmangukiya@hotmail.com (Tarun Mangukiya) |
Package Create Date: | 2015-11-07 |
Package Last Update: | 2018-06-11 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-25 15:05:28 |
Package Statistics | |
---|---|
Total Downloads: | 372 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 12 |
Total Watchers: | 2 |
Total Forks: | 7 |
Total Open Issues: | 1 |
Laravel Image Resizer is a Laravel 5.x Package for Image uploading, auto re-sizing and retrieving library. The package allows to define types of images and their directories to upload image, apply transformations on them using Intervention Image such as Crop and Rotate, and save different types of images (such as small, medium, large) using sync or push the job on to Laravel Queue.
Begin by installing this package through Composer.
{
"require": {
"tarunmangukiya/laravel-image-resizer": "dev-master"
}
}
Laravel Image Resizer requires a configuration file for images to be resized. To get started, you'll need to publish all vendor assets:
php artisan vendor:publish
You can add the --provider="TarunMangukiya\ImageResizer\ImageResizerServiceProvider"
option to only publish assets of the Image Resizer package.
This will create a config/imageresizer.php
file in your app that you can modify to set your configuration. Also, make sure you check for changes compared to the original config file after an upgrade.
We have defined a sample configuration file for your reference.
return array(
'types' => [
'profile' => [
'original' => storage_path() . '/profile',
'crop' => [
'enabled' => false,
'uncropped_image' => storage_path() . '/profile/uncropped',
],
'compiled' => 'images/profile',
'default' => 'images/profile-default.jpg',
'sizes' => [
'small' => [100, 100, 'fit', 'jpg'],
'large' => [400, null, 'stretch']
]
],
],
);
Here in this config file we have defined one image type profile
and the location of original
image storage, compiled
(resized) images location, sizes
of the images that has to be resized like small
, large
, etc.
We have also defined default
image to be returned in case of original image does not exists.
Thus, by using this basic configuration your profile image will be saved in original, small and large format with their defined respective sizes.
You can upload & resize your images both from File Input or from URL.
If you want to process your image from File Input, you just need to write
$file = \ImageResizer::upload('profile', 'file_input_name', $output_file_name);
or pass an url of the image file
$url = 'https://invinciblengo.org/photos/slider/large/dalhousie-winter-trekking-expedition-himachal-pradesh-2RV7Udy-1337x390.jpg';
$file = \ImageResizer::upload('profile', $url, $output_file_name);
At the time of retrieval of image,
<img src="{{ ImageResizer::get('profile', 'small', $filename) }}">
All the options available for config are defined in config file (imageresizer.php) of the package.
You can write me at @tarunmangukiya for additional information.
Don't forget to provide your suggestions and reviews for continuous improvements.