PHPackages                             phpsamurai/image-conversion - 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. phpsamurai/image-conversion

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

phpsamurai/image-conversion
===========================

A simple laravel package for converting media images to WebP format

v1.0.3(1y ago)16MITPHPPHP ^8.0

Since Nov 7Pushed 1y ago1 watchersCompare

[ Source](https://github.com/0x3b3fc/image-conversion-webp)[ Packagist](https://packagist.org/packages/phpsamurai/image-conversion)[ RSS](/packages/phpsamurai-image-conversion/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (5)Used By (0)

Laravel Image Converter To WebP
===============================

[](#laravel-image-converter-to-webp)

- This package converts images in your Laravel application to WebP format, helping to reduce file sizes and optimize loading speeds.

Author: Sief Hesham
-------------------

[](#author-sief-hesham)

### Contact:

[](#contact-devsiefheshamgmailcom)

1. Requirements
---------------

[](#1-requirements)

- PHP: 8.0 or above
- Laravel: 10 or above

Packages
--------

[](#packages)

- Spatie Image: For image manipulation.
- Spatie Laravel Media Library: For managing media files.

2. Installation
---------------

[](#2-installation)

- Step 1: Require the Package To install the package, run the following command in your Laravel project's root directory:

```
composer require phpsamurai/image-conversion:"^1.0.3" -W
```

- step 2: Publish the Configuration File, Run the following command to publish the package configuration file:

```
php artisan vendor:publish --provider="phpsamurai\ImageConversion\ImageConversionServiceProvider"
```

- Step 3: update the .env file with the following configuration:

```
IMAGE_FOLDER=youre-image-folder-name
WEBP_QUALITY=85
IMAGE_CONVERSION_USE_QUEUE=true
```

This will add the package to your project's dependencies and make it available in your application.

3. Configuration
----------------

[](#3-configuration)

- Step 1: Set Up Queue Configuration (Optional) The package uses Laravel’s job dispatching system to convert images asynchronously. If you haven't already configured a queue driver, consider using database, redis, or another supported driver to handle background jobs.
- Open the .env file and set your QUEUE\_CONNECTION to a non-sync driver (e.g., database or redis).

```
QUEUE_CONNECTION=database
```

Run Migrations to create the necessary database table for queued jobs if you choose the database driver:

```
php artisan queue:table
php artisan migrate
```

Start the Queue Worker to process jobs:

```
php artisan queue:work
```

This step is optional but recommended for large numbers of images, as the package will otherwise process conversions synchronously, which could impact performance.

4. Usage
--------

[](#4-usage)

### Step 1: Run the Conversion Command

[](#step-1-run-the-conversion-command)

Once the package is installed, you can use the following Artisan command to convert images in your media library to WebP format.

```
php artisan media:convert-to-webp
```

### Command Description

[](#command-description)

#### Purpose

[](#purpose)

- Converts all images in the media library to WebP format.

#### Process

[](#process)

- Fetches all media files with image MIME types (image/jpeg, image/png, etc.) that aren’t already in WebP format.
- Dispatches a job (ConvertImageToWebPJob) for each image, converting it to WebP format and updating the database record.
- Output: Displays a confirmation message once all jobs have been dispatched.
- Note: Each image is converted and stored as a WebP file, replacing the original format in the database and on disk.

### Step 2: Monitor Job Progress (If Using Queues)

[](#step-2-monitor-job-progress-if-using-queues)

- If you're running the command asynchronously with a queue driver (e.g., database or redis), the conversion jobs will be added to your queue. You can monitor the progress of these jobs via your preferred queue monitoring tool or by viewing the queue database table.
- Example Queue Worker Command To run the queue worker in the background:

```
php artisan queue:work
```

5. Additional Information
-------------------------

[](#5-additional-information)

Image Conversion Details

- The package uses the Spatie Image package to convert images to WebP format. During conversion, the following steps occur:
- The original image file path is identified and processed. A new WebP file is generated.
- The original image file is replaced by the WebP file in the storage location. The media record in the database is updated with the new file name and MIME type (image/webp).

Important Notes
---------------

[](#important-notes)

- Image Formats Supported: The package will convert `JPEG, JPG, and PNG` formats to WebP. Any other formats will be ignored.
- Data Integrity: The database records for each media file are updated to reflect the new file name and MIME type after conversion.
- Overwriting Files: Each converted WebP file will replace the original image file, so make sure you have backups if you need to keep original formats.

6. Troubleshooting
------------------

[](#6-troubleshooting)

### Common Issues

[](#common-issues)

- Queue Not Processing Jobs: Make sure your queue worker is running (php artisan queue:work). Also, check that your QUEUE\_CONNECTION in .env is correctly set to database, redis, or another valid driver.
- File Permission Errors: Ensure that your storage directory has the correct permissions, especially if you're using local storage `(storage/app)`.
- Image Conversion Failures: If an image cannot be converted, ensure that Spatie Image is properly installed and that the image file is accessible.

7. License
----------

[](#7-license)

This package is open-sourced software licensed under the MIT license.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

557d ago

PHP version history (2 changes)v1.0.0PHP ^8.2

v1.0.1PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/f22a01a2535b7524837de32d6037d2fb7040cc0ac0419b39ea23bcecab7786d1?d=identicon)[0x3b3fc](/maintainers/0x3b3fc)

---

Top Contributors

[![0x3b3fc](https://avatars.githubusercontent.com/u/65143991?v=4)](https://github.com/0x3b3fc "0x3b3fc (11 commits)")

---

Tags

phplaravelimagespngjpegjpgfilamentWebpspladephpsamurai

### Embed Badge

![Health badge](/badges/phpsamurai-image-conversion/health.svg)

```
[![Health](https://phpackages.com/badges/phpsamurai-image-conversion/health.svg)](https://phpackages.com/packages/phpsamurai-image-conversion)
```

###  Alternatives

[picqer/php-barcode-generator

An easy to use, non-bloated, barcode generator in PHP. Creates SVG, PNG, JPG and HTML images from the most used 1D barcode standards.

1.8k25.5M88](/packages/picqer-php-barcode-generator)[rosell-dk/webp-convert

Convert JPEG &amp; PNG to WebP with PHP

6038.1M54](/packages/rosell-dk-webp-convert)[choowx/rasterize-svg

A PHP library for converting SVG to JPEG, PNG, and WEBP

2261.7k](/packages/choowx-rasterize-svg)[tomatophp/filament-media-manager

Manage your media files using spatie media library with easy to use GUI for FilamentPHP

14543.9k3](/packages/tomatophp-filament-media-manager)[rosell-dk/webp-convert-cloud-service

Cloud service for converting JPEG &amp; PNG to WebP

545.6k3](/packages/rosell-dk-webp-convert-cloud-service)[tihiy-production/php-image-compressor

ImageCompressor - this is an easy way to compress images on the fly

243.8k](/packages/tihiy-production-php-image-compressor)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
