PHPackages                             eyadhamza/laravel-webp - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. eyadhamza/laravel-webp

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

eyadhamza/laravel-webp
======================

This is my package laravel-webp

v2.0.0(2y ago)192931MITPHPPHP ^8.1

Since Oct 10Pushed 2y ago2 watchersCompare

[ Source](https://github.com/Eyadhamza/Laravel-Webp)[ Packagist](https://packagist.org/packages/eyadhamza/laravel-webp)[ Docs](https://github.com/eyadhamza/laravel-webp)[ GitHub Sponsors](https://github.com/:vendor_name)[ RSS](/packages/eyadhamza-laravel-webp/feed)WikiDiscussions main Synced yesterday

READMEChangelog (10)Dependencies (9)Versions (20)Used By (0)

Laravel WebP
============

[](#laravel-webp)

[![Latest Version on Packagist](https://camo.githubusercontent.com/7a73dc995c0e53406ada2518f2e4f1327e8c11024276d2cccd4d376fc85aa871/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6579616468616d7a612f6c61726176656c2d776562702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/eyadhamza/laravel-webp)

[![GitHub Code Style Action Status](https://camo.githubusercontent.com/017daa454aab48df952be17faaf5549daf345c4d272c8cca12de06a051f8e28a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6579616468616d7a612f6c61726176656c2d776562702f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/eyadhamza/laravel-webp/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/5b2e70e2fe43650626ad3d3335d71b0cd2b6c3b957a83d5e70108dd18c419fe4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6579616468616d7a612f6c61726176656c2d776562702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/eyadhamza/laravel-webp)

---

This Laravel package is a simple wrapper for the [PHP Intervention Library](http://image.intervention.io/) to provide a more straightforward interface and convenient way to convert images to the WebP format - a next-generation image format - and resize them to render only the needed sizes.

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

[](#installation)

You can install the package via composer:

```
composer require eyadhamza/laravel-webp
```

Publish the config file with:

```
php artisan vendor:publish --provider="EyadHamza\LaravelWebp\LaravelWebpServiceProvider" --tag="webp-config"
```

The contents of the published config file:

```
return [
    'quality' => 70,
    'height' => null,
    'width' => null,
    'overwrite' => true
];
```

Usage
-----

[](#usage)

### Converting / Resizing Images in Eloquent Models:

[](#converting--resizing-images-in-eloquent-models)

To convert images in Eloquent Models, all you need to do is to add a cast to the image columns in your model:

```
class TestModel extends Model
{
    protected $casts = [
        'image' => ToWebpCast::class . ':200,200,100',
        'avatar' => ToWebpCast::class,
    ];
}
```

The `ToWebpCast` class takes three optional parameters: width, height, and quality. You can also pass the values in the config file as default values. In the config file, set the `overwrite` value to `true` or `false`; if set to `true`, the old image will be deleted.

Now, whenever you set the image attribute, it will be converted to WebP and resized to the specified dimensions—if given.

### Optimize Existing Images:

[](#optimize-existing-images)

If you already have images on your local storage that are not optimized, and their paths are stored in the database, you can use the following Artisan command:

```
php artisan public:to-webp
```

To convert images in a specific directory:

```
php artisan public:to-webp --directory='public/images'
```

To delete old images, use the `--overwrite` option:

```
php artisan public:to-webp --overwrite
```

For optimizing files in static assets, use:

```
php artisan public:to-webp --assets
```

To modify the database attribute values to point to the new webp image, run:

```
php artisan images:to-webp Post
```

If you want more methods to conveniently change your image path, refer to the `ImageToWebpService` class.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Eyad Hamza](https://github.com/Eyadhamza)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity68

Established project with proven stability

 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 ~49 days

Recently: every ~159 days

Total

17

Last Release

888d ago

Major Versions

v1.3.5 → v2.0.02023-12-06

PHP version history (2 changes)1.0.0PHP 7.4.\*|^8.0

v2.0.0PHP ^8.1

### Community

Maintainers

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

---

Top Contributors

[![Eyadhamza](https://avatars.githubusercontent.com/u/65258058?v=4)](https://github.com/Eyadhamza "Eyadhamza (108 commits)")

---

Tags

laravellaravel-webpeyadhamza

###  Code Quality

TestsPest

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/eyadhamza-laravel-webp/health.svg)

```
[![Health](https://phpackages.com/badges/eyadhamza-laravel-webp/health.svg)](https://phpackages.com/packages/eyadhamza-laravel-webp)
```

###  Alternatives

[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)

PHPackages © 2026

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