Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Image Sanitize

Laravel Image Sanitize Laravel Package

laravel-at/laravel-image-sanitize

Laravel package to sanitize images on upload by stripping EXIF/metadata, normalizing orientation, and re-encoding to safer formats. Helps reduce privacy leaks and potential payloads while keeping image quality and integrating cleanly with Laravel apps.

View on GitHub
Deep Wiki
Context7

Prevent malicious code execution through uploaded image files

Frequently asked questions about Laravel Image Sanitize
How do I integrate this package into my Laravel app’s upload flow?
Use the package’s `Sanitizer` class directly in your controller or middleware. For example, after validating a file, pass it to `$sanitizer->sanitize($filePath)` before saving. It also supports a custom validation rule (`sanitized`) for form requests.
Which Laravel versions are officially supported?
The package is designed for Laravel 10+ and leverages its service container and validation system. Check the package’s `composer.json` for the exact version range, as minor updates may align with Laravel releases.
Does this package work with cloud storage like S3?
Yes, the package operates on the file data before it’s stored, so it works seamlessly with Laravel’s `Storage` facade, including S3, GCS, and local storage. Just ensure your storage backend supports temporary file handling during sanitization.
Can I configure which metadata fields are removed?
The package removes all EXIF, IPTC, and XMP metadata by default, but you can customize the sanitization depth via configuration. For example, you might allow basic ICC profiles while stripping geolocation data.
What happens if an image fails sanitization (e.g., corrupt file)?
The package throws an exception if sanitization fails, which you can catch and handle gracefully. For production, consider logging failures and implementing a fallback (e.g., rejecting the upload or notifying admins).
Is there a performance impact when sanitizing large batches of images?
Sanitization adds CPU overhead, especially for high-resolution images. For bulk uploads, offload the process to a queue (e.g., Laravel queues) or use a dedicated microservice to avoid blocking requests.
Does this package support SVG or other non-traditional image formats?
The package focuses on traditional raster formats (JPEG, PNG, GIF, WEBP) and removes metadata from them. SVG sanitization requires additional libraries (e.g., `svg-sanitizer`), so handle SVGs separately if needed.
How can I test this package in my CI pipeline?
Include test images with embedded metadata (e.g., EXIF geotags) and malicious payloads (e.g., shellcode in PNG comments) in your test suite. Verify the package removes metadata and rejects unsafe files while preserving valid ones.
Are there alternatives to this package for Laravel image sanitization?
Alternatives include custom scripts using PHP’s `exif_read_data()` or libraries like `imagick`, but they lack Laravel integration. Other packages like `spatie/laravel-medialibrary` offer some sanitization but aren’t as focused on security.
Can I use this package without Laravel’s validation system?
Yes, the core `Sanitizer` class is framework-agnostic and can be used in vanilla PHP. However, Laravel-specific features (e.g., validation rules, middleware) require the full Laravel ecosystem.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor