Laravel package for resizing images. Supports PNG, JPG, JPEG, GIF.
Getting Started
Installation
How to Use
Download Postman API
Image Resize
Sample Image Resize API
How To Implement Image Resize Service
Common Issues Encountered
Support
Below are the steps in order to integrate image resize API to your Laravel project.
Install the package using composer:
composer require jscustom/laravel-image-resize
Export the configuration file:
php artisan vendor:publish --provider="JSCustom\ImageResize\Providers\ImageResizeServiceProvider" --tag="config"
Download the Postman API Collection here.
Features
- Resize
- Crop
- Change Quality
Service
JSCustom\ImageResize\Services\ImageResizeService
Controller
JSCustom\ImageResize\Http\Controllers\ImageResize\ImageResizeController
URL
{{url}}/api/image-resize
Form Data
{
"image": `FILE`,
"width": 150,
"height": 150,
"quality": 75,
"option": "crop"
}
Method
POST
Headers
{
"Content-Type": "multipart/form-data"
}
Response
{
"status": true,
"code": 201,
"message": "Image has been created. Please see PUBLIC\\PATH\\OF\\RESIZED\\IMAGE\\2141667567259_DSC05028-Edit_FB.jpg",
"payload": {
"image": "PUBLIC\\PATH\\OF\\RESIZED\\IMAGE\\2141667567259_DSC05028-Edit_FB.jpg"
}
}
Add the service to your controller
use JSCustom\ImageResize\Services\ImageResizeService;
In your controller, follow this code structure
$image = ImageResizeService::imageResize($request);
Or initiate in the construct of your controller
public function __construct(
\JSCustom\ImageResize\Services\ImageResizeService $ImageResizeService
) {
$this->_imageResizeService = $ImageResizeService;
}
Then follow this code structure
$image = $this->_imageResizeService->imageResize($request);
GD error(s)
For PHP8.0 use (php8.1-gd and php8.2-gd are also available):
sudo apt-get install php8.0-gd
For PHP7.0 use (php7.1-gd, php7.2-gd, php7.3-gd and php7.4-gd are also available):
sudo apt-get install php7.0-gd
For support, email developer.jeddsaliba@gmail.com.