PHPackages                             laravel-at/laravel-image-sanitize - 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. laravel-at/laravel-image-sanitize

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

laravel-at/laravel-image-sanitize
=================================

A small but handy package to prevent malicious code execution coming into your application through uploaded image files.

v3.0.0(1y ago)26056.7k↑94.1%19MITPHPPHP ^8.2CI failing

Since Sep 3Pushed 1y ago12 watchersCompare

[ Source](https://github.com/laravel-at/laravel-image-sanitize)[ Packagist](https://packagist.org/packages/laravel-at/laravel-image-sanitize)[ Docs](https://github.com/laravel-at/laravel-image-sanitize)[ RSS](/packages/laravel-at-laravel-image-sanitize/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (16)Used By (0)

[![Laravel Image Sanitize logo](https://raw.githubusercontent.com/laravel-at/laravel-image-sanitize/master/art/logo.png)](https://raw.githubusercontent.com/laravel-at/laravel-image-sanitize/master/art/logo.png)

It prevents malicious code execution!
=====================================

[](#it-prevents-malicious-code-execution)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b35a5cea7688a8a3084d071fc24ed54e84280c7b2405fc9344d9ff93e33b854f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c61726176656c2d61742f6c61726176656c2d696d6167652d73616e6974697a652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-at/laravel-image-sanitize)[![GitHub Tests Action Status](https://github.com/laravel-at/laravel-image-sanitize/workflows/tests/badge.svg)](https://github.com/laravel-at/laravel-image-sanitize/actions)[![Quality Score](https://camo.githubusercontent.com/c6ee5f71f7f6f3c5d11776b13a526799d80eaec3497c553a948896cff00b7af9/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6c61726176656c2d61742f6c61726176656c2d696d6167652d73616e6974697a652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/laravel-at/laravel-image-sanitize)[![Total Downloads](https://camo.githubusercontent.com/c097477e047d75a606ef00d392e03f52ac43365b98f54e005e853ad077040fc1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c61726176656c2d61742f6c61726176656c2d696d6167652d73616e6974697a652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-at/laravel-image-sanitize)

This is a small but handy package to prevent malicious code execution coming into your application through uploaded images. It was created after being inspired by [@appelsiini](https://github.com/appelsiini)'s [talk on How to Hack your Laravel Application](https://speakerdeck.com/anamus/how-your-laravel-application-can-get-hacked-f7acca32-3721-4c06-9a2e-5965cd9a4a29)

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

[](#installation)

You can install the package via composer:

```
composer require laravel-at/laravel-image-sanitize
```

Usage
-----

[](#usage)

Register the `ImageSanitizeMiddleware` in your `App\Http\Kernel` class

```
protected $routeMiddleware = [
    // ...
    'image-sanitize' => \LaravelAt\ImageSanitize\ImageSanitizeMiddleware::class,
];
```

Then, just use it in your Controller's constructor

```
public function __construct()
{
    $this->middleware('image-sanitize');
}
```

Or use it in your `routes/web.php` file

```
Route::post('/files', 'FileController@upload')
    ->name('file.upload')
    ->middleware(['image-sanitize']);
```

If you want to learn more about `middlewares`, please check out the [official Laravel documentation](https://laravel.com/docs/master/middleware)

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

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

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

[](#contributing)

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

### Security

[](#security)

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

Credits
-------

[](#credits)

- [Adrian Nürnberger](https://github.com/nuernbergerA)
- [Mathias Onea](https://github.com/mathiasonea)
- Logo by [Caneco](https://github.com/caneco)

License
-------

[](#license)

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

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance44

Moderate activity, may be stable

Popularity49

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 56.8% 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 ~143 days

Recently: every ~279 days

Total

15

Last Release

442d ago

Major Versions

1.5.0 → v2.0.02022-02-10

v2.2.0 → v3.0.02025-03-03

PHP version history (5 changes)v1.0PHP ^7.2

1.5.0PHP ^7.2|^8.0

v2.0.1PHP ^8.0

v2.1.0PHP ^8.1

v3.0.0PHP ^8.2

### Community

Maintainers

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

---

Top Contributors

[![nuernbergerA](https://avatars.githubusercontent.com/u/13331388?v=4)](https://github.com/nuernbergerA "nuernbergerA (50 commits)")[![mathiasonea](https://avatars.githubusercontent.com/u/9391581?v=4)](https://github.com/mathiasonea "mathiasonea (26 commits)")[![C0kkie](https://avatars.githubusercontent.com/u/20169938?v=4)](https://github.com/C0kkie "C0kkie (3 commits)")[![koenhoeijmakers](https://avatars.githubusercontent.com/u/2232776?v=4)](https://github.com/koenhoeijmakers "koenhoeijmakers (2 commits)")[![chapeupreto](https://avatars.githubusercontent.com/u/834048?v=4)](https://github.com/chapeupreto "chapeupreto (2 commits)")[![su-rowel](https://avatars.githubusercontent.com/u/93464247?v=4)](https://github.com/su-rowel "su-rowel (1 commits)")[![caneco](https://avatars.githubusercontent.com/u/502041?v=4)](https://github.com/caneco "caneco (1 commits)")[![jason-nabooki](https://avatars.githubusercontent.com/u/52981451?v=4)](https://github.com/jason-nabooki "jason-nabooki (1 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (1 commits)")[![bleuscyther](https://avatars.githubusercontent.com/u/2999487?v=4)](https://github.com/bleuscyther "bleuscyther (1 commits)")

---

Tags

hacktoberfestimagelaravel-image-sanitize

### Embed Badge

![Health badge](/badges/laravel-at-laravel-image-sanitize/health.svg)

```
[![Health](https://phpackages.com/badges/laravel-at-laravel-image-sanitize/health.svg)](https://phpackages.com/packages/laravel-at-laravel-image-sanitize)
```

###  Alternatives

[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.3M74](/packages/unisharp-laravel-filemanager)[intervention/image-laravel

Laravel Integration of Intervention Image

1536.5M102](/packages/intervention-image-laravel)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[joshembling/image-optimizer

Optimize your Filament images before they reach your database.

111145.4k12](/packages/joshembling-image-optimizer)[aedart/athenaeum

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

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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