jscustom/laravel-image-resize

Laravel package for resizing images. Supports PNG, JPG, JPEG, GIF.

2.0.0 2024-01-14 14:59 UTC

This package is auto-updated.

Last update: 2025-03-14 17:30:26 UTC


README

Laravel package for resizing images. Supports PNG, JPG, JPEG, GIF.

Table of Contents

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

Getting Started

Below are the steps in order to integrate image resize API to your Laravel project.

Installation

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"

How To Use

Download Postman API

Download the Postman API Collection here.

Image Resize

Features

  • Resize
  • Crop
  • Change Quality

Service

JSCustom\ImageResize\Services\ImageResizeService

Sample Image Resize API

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"
    }
}

How To Implement Image Resize Service

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);

Common Issues Encountered

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

Support

For support, email developer.jeddsaliba@gmail.com.