Download the PHP package laravel-at/laravel-image-sanitize without Composer
On this page you can find all versions of the php package laravel-at/laravel-image-sanitize. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download laravel-at/laravel-image-sanitize
More information about laravel-at/laravel-image-sanitize
Files in laravel-at/laravel-image-sanitize
Package laravel-image-sanitize
Short Description A small but handy package to prevent malicious code execution coming into your application through uploaded image files.
License MIT
Homepage https://github.com/laravel-at/laravel-image-sanitize
Informations about the package laravel-image-sanitize

Reduce the risk of malicious code execution!
This is a small but handy package to reduce the risk of malicious code execution coming into your application through uploaded images. It was created after being inspired by @appelsiini's talk on How to Hack your Laravel Application
Installation
This version requires PHP 8.3+, Laravel 12 or 13, and Intervention Image 4.
You can install the package via composer:
Usage
Apply the middleware to routes that receive image uploads:
If you prefer a middleware alias, register it in your application's bootstrap/app.php file:
Then use the alias on your upload routes:
If you want to learn more about middlewares, please check out the official Laravel documentation.
Configuration
You may publish the configuration file:
The default configuration scans JPEG, PNG, GIF, BMP, and WebP uploads for suspicious byte patterns, then re-encodes matching images through Intervention Image. SVG files are not supported by default.
These defaults are a starting point. You may extend the patterns array with application-specific patterns while retaining the defaults. Contributions that benefit the broader community are welcome.
You can also use the facade directly:
Pattern matching is case-insensitive, so <?php also detects variants such as <?PHP; you do not need to list each casing separately.
Published configuration files are not updated automatically. When upgrading, compare your application's patterns array with the package defaults.
Pattern scanning and image re-encoding are defense-in-depth measures. Applications should still validate file types and sizes, generate safe filenames, and store uploads in a location where they cannot be executed.
Testing
Run the full local quality check:
Or run the individual checks:
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Adrian Nürnberger
- Mathias Onea
- Logo by Caneco
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-image-sanitize with dependencies
ext-fileinfo Version *
illuminate/container Version ^12.0|^13.0
illuminate/contracts Version ^12.0|^13.0
illuminate/http Version ^12.0|^13.0
illuminate/support Version ^12.0|^13.0
intervention/image Version ^4.0