PHPackages                             ngfw/webpconverter - 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. ngfw/webpconverter

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

ngfw/webpconverter
==================

A Laravel package that automatically converts images to WebP format, serves them efficiently, and caches the converted files to optimize performance.

v1.0.1(1y ago)1385MITPHPPHP ^8.0

Since Aug 25Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/ngfw/WebpConverter)[ Packagist](https://packagist.org/packages/ngfw/webpconverter)[ Docs](https://github.com/ngfw/webpconverter)[ RSS](/packages/ngfw-webpconverter/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (9)Versions (4)Used By (0)

WebP Converter Package
======================

[](#webp-converter-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/15b888a030bcf9dd1e1490089a3f4d7b5f88e2f1aff412d3d7c3983a08f04363/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6766772f57656270436f6e7665727465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ngfw/WebpConverter)[![Total Downloads](https://camo.githubusercontent.com/79f7b64a5388604f67048528b0c55fb6764231a00aab88ea7eb6c9a44aaef58a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e6766772f57656270436f6e7665727465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ngfw/WebpConverter)

The WebP Converter package is your go-to tool for converting images to the WebP format. It’s built to make your images smaller, faster, and more efficient without sacrificing quality. Whether you're dealing with JPEGs, PNGs, or even BMPs, this package handles them all with ease. It supports both GD and Imagick drivers, giving you flexibility depending on your server environment. And yes, it’s PSR-4 compliant, so it fits seamlessly into your modern PHP projects.

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require ngfw/WebpConverter
```

After installing the package, you may want to publish the configuration file to customize the settings according to your project’s needs. To publish the configuration file, run the following command:

```
php artisan vendor:publish --tag="webp_converter"
```

This will create a webp\_converter.php file in your config directory. Inside this file, you can configure the following options:

*driver*: Specifies the image processing library to use (gd or imagick).

*quality*: Sets the default quality for WebP conversion.

*storage\_path*: Defines the default storage path for the converted WebP images.

Example configuration file (config/webp\_converter.php):

```
return [

    /*
    * Default Image Processing Driver
    */
    'driver' => env('WEBP_CONVERTER_DRIVER', 'gd'),

    /*
    * Default WebP Quality
    */
    'quality' => env('WEBP_CONVERTER_QUALITY', 80),

    /*
    * Storage Path
    */

    'storage_path' => env('WEBP_CONVERTER_STORAGE_PATH', 'public/webp_images'),
];
```

You can then customize these settings as needed to better fit your application’s requirements.

Usage
-----

[](#usage)

Using the WebP Converter is super simple. Here’s how you can integrate it into your project:

**Loading an Image:**

You can load an image from a local path or even a remote URL. The package is smart enough to handle both.

```
use Ngfw\WebpConverter\WebpConverterFacade as WebpConverter;

// Load a local image
// WebpConverter::load('/path/to/image.jpg');

// Load a remote image
$imgUrl = "https://images.unsplash.com/photo-1724169913051-49f6ff76a070?q=80&w=3570&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D";

$image = WebpConverter::load($imgUrl)->convert();
// /storage/webp_images/photo-1724169913051-49f6ff76a070.webp
```

Example of generating Thumbnail image:

```
$thumbnailUrl = WebpConverter::load($imgUrl)
        ->width(200)
        ->quality(70) // Set the quality for optimization
        ->optimize() // Apply optimization
        ->saveAs('optimized_thumbnail')
        ->convert();
// /storage/webp_images/optimized_thumbnail.webp
```

**Setting Quality:**

Want to control the quality of the output WebP image? No problem. Adjust the quality easily.

```
$converter->quality(80); // Set quality to 80%
```

**Resizing the Image:**

Need to resize the image? Just specify the width and height.

```
$converter->width(300)->height(200); // Resize to 300x200
```

**Optimizing the Image:**

Optimize your image to reduce file size even further. The package applies smart optimizations to deliver the best results.

```
$converter->optimize();
```

**Converting to WebP:**

Finally, convert your image to WebP. You can even specify a custom filename for the output.

```
$webpUrl = $converter->saveAs('optimized_image')->convert();
echo $webpUrl; // Outputs the URL to the converted WebP image
```

**Chaining Multiple Methods:**

You can chain multiple methods for a concise, single-line conversion:

```
$webpUrl = $converter->load('/path/to/image.jpg')
                     ->quality(90)
                     ->width(500)
                     ->height(300)
                     ->optimize()
                     ->saveAs('final_image')
                     ->convert();
echo $webpUrl; // Outputs the URL to the optimized WebP image
```

**Serving the Image:**

Serve the WebP image directly, or get the raw data if you need to do something custom.

```
$content = $converter->serve(true); // Serve the image as a response array
```

### Blade Examples

[](#blade-examples)

Here are a couple of examples on how to use the WebP Converter in a Blade template:

**Local Image Conversion:**Convert a local image using Laravel's asset helper:

```

```

This will convert the image located at public/images/png1.png into WebP format and serve it.

**Remote Image Conversion:**

Convert an image from a remote URL:

```

```

This will download the image from the specified URL, convert it to WebP format, and then serve it.

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email the author instead of using the issue tracker.

Credits
-------

[](#credits)

- [Nick G](https://github.com/ngfw)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance55

Moderate activity, may be stable

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60% 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

2

Last Release

626d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fd40929eda2ffab2359616a80e7d05b6bacc32dc68203f5938a9da8badde8d37?d=identicon)[gejadze](/maintainers/gejadze)

---

Top Contributors

[![ngfw](https://avatars.githubusercontent.com/u/203863?v=4)](https://github.com/ngfw "ngfw (3 commits)")[![claude](https://avatars.githubusercontent.com/u/81847?v=4)](https://github.com/claude "claude (2 commits)")

---

Tags

ngfwlaravel webpconverterwebpconverter

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ngfw-webpconverter/health.svg)

```
[![Health](https://phpackages.com/badges/ngfw-webpconverter/health.svg)](https://phpackages.com/packages/ngfw-webpconverter)
```

###  Alternatives

[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[spatie/laravel-og-image

Generate OG images for your Laravel app

305.2k](/packages/spatie-laravel-og-image)[daun/statamic-placeholders

Generate low-quality image placeholders for lazyloading Statamic assets

106.6k](/packages/daun-statamic-placeholders)[abordage/laravel-og-images

Generate Open Graph images (og:image, twitter:image, vk:image) for each site pages

122.8k](/packages/abordage-laravel-og-images)[daun/statamic-mux

Seamless video encoding and streaming using Mux on Statamic sites

132.3k](/packages/daun-statamic-mux)

PHPackages © 2026

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