PHPackages                             vishal-pawar/image-convert - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. vishal-pawar/image-convert

ActiveLibrary[Image &amp; Media](/categories/media)

vishal-pawar/image-convert
==========================

this package can convert you image into webp and desired resolution

v2.0.0(1y ago)15MITPHP

Since Mar 27Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Vishalsinghpawargit/image-conversion)[ Packagist](https://packagist.org/packages/vishal-pawar/image-convert)[ RSS](/packages/vishal-pawar-image-convert/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (2)Dependencies (2)Versions (5)Used By (0)

🖼️ Image Convert
================

[](#️-image-convert)

> A powerful PHP package for converting images to WebP format and resizing them with optional object storage support.

[![Latest Version](https://camo.githubusercontent.com/848150931a3015de1251f3d7b36fd97016881708c25e2f077ce654a366d2b412/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f76697368616c2d70617761722f696d6167652d636f6e76657274)](https://packagist.org/packages/vishal-pawar/image-convert)[![PHP Version](https://camo.githubusercontent.com/55c34b6c8b7b0f327c65b6c39d882a2dcbeaed43dc31555345d44b6a1bcc81f6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f76697368616c2d70617761722f696d6167652d636f6e76657274)](https://packagist.org/packages/vishal-pawar/image-convert)[![License](https://camo.githubusercontent.com/88f26149ce60cbf1c78b5f22ae183d77481e7774b2bcb6dc1f83e8d7b714f5ba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f76697368616c2d70617761722f696d6167652d636f6e76657274)](https://packagist.org/packages/vishal-pawar/image-convert)[![Total Downloads](https://camo.githubusercontent.com/eca7f66005e704ade9225a22baa596fa300b0eeedc7f2664be9aadfe783f3c9d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f76697368616c2d70617761722f696d6167652d636f6e76657274)](https://packagist.org/packages/vishal-pawar/image-convert)

✨ Features
----------

[](#-features)

- 🚀 **Fast WebP Conversion** - Convert JPG/PNG images to WebP format
- 📐 **Smart Resizing** - Resize images to desired dimensions
- ☁️ **Object Storage Support** - Save directly to cloud storage (DigitalOcean Spaces, AWS S3)
- 🎯 **Simple API** - Easy-to-use helper functions
- 🔧 **Laravel Integration** - Seamless integration with Laravel applications

📦 Installation
--------------

[](#-installation)

Install the package via Composer:

```
composer require vishal-pawar/image-convert:v1.0.0
```

🚀 Quick Start
-------------

[](#-quick-start)

```
use VishalPawar\ImageConvert\helper\ImageHelper;

// Convert and save as WebP
$result = ImageHelper::saveWebpImage("uploads/images", $request->image);

// Resize and convert to WebP
$result = ImageHelper::resizeSaveWebpImage("uploads/images", $request->image, 800, 600);
```

📚 API Reference
---------------

[](#-api-reference)

### Available Methods

[](#available-methods)

MethodDescription`saveImage()`Save image in original format`resizeSaveImage()`Resize and save image`saveWebpImage()`Convert to WebP and save`resizeSaveWebpImage()`Resize, convert to WebP and save### Method Details

[](#method-details)

#### `saveImage(path, image, objectStore?)`

[](#saveimagepath-image-objectstore)

Save an image in its original format.

**Parameters:**

- `path` (string) - Directory path (e.g., 'uploads/images')
- `image` (file) - Image file object
- `objectStore` (boolean, optional) - Enable object storage (default: false)

**Example:**

```
Route::post('upload', function(Request $request) {
    return ImageHelper::saveImage("uploads/posts", $request->image);
});
```

#### `resizeSaveImage(path, image, height, width, objectStore?)`

[](#resizesaveimagepath-image-height-width-objectstore)

Resize and save an image.

**Parameters:**

- `path` (string) - Directory path
- `image` (file) - Image file object
- `height` (int) - Target height in pixels
- `width` (int) - Target width in pixels
- `objectStore` (boolean, optional) - Enable object storage (default: false)

**Example:**

```
Route::post('upload', function(Request $request) {
    return ImageHelper::resizeSaveImage("uploads/posts", $request->image, 320, 320);
});
```

#### `saveWebpImage(path, image, objectStore?)`

[](#savewebpimagepath-image-objectstore)

Convert image to WebP format and save.

**Parameters:**

- `path` (string) - Directory path
- `image` (file) - Image file object
- `objectStore` (boolean, optional) - Enable object storage (default: false)

**Example:**

```
Route::post('upload', function(Request $request) {
    return ImageHelper::saveWebpImage("uploads/posts", $request->image);
});
```

#### `resizeSaveWebpImage(path, image, height, width, objectStore?)`

[](#resizesavewebpimagepath-image-height-width-objectstore)

Resize image and convert to WebP format.

**Parameters:**

- `path` (string) - Directory path
- `image` (file) - Image file object
- `height` (int) - Target height in pixels
- `width` (int) - Target width in pixels
- `objectStore` (boolean, optional) - Enable object storage (default: false)

**Example:**

```
Route::post('upload', function(Request $request) {
    return ImageHelper::resizeSaveWebpImage("uploads/posts", $request->image, 800, 600);
});
```

☁️ Object Storage Configuration
-------------------------------

[](#️-object-storage-configuration)

To enable object storage functionality, create a configuration file:

### Step 1: Create Config File

[](#step-1-create-config-file)

Create `app/config/ImageConvert.php`:

```
