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
Imagine Svg

Imagine Svg Laravel Package

contao/imagine-svg

Imagine-compatible SVG image library for PHP/Contao. Open, crop, resize, and apply common effects (gamma, grayscale, blur, etc.) to SVGs and save results. Includes SVG-aware sizing via SvgBox for absolute, aspect-ratio, or undefined dimensions.

View on GitHub
Deep Wiki
Context7

Contao Imagine SVG Library

Frequently asked questions about Imagine Svg
How do I install contao/imagine-svg in a Laravel project?
Run `composer require contao/imagine-svg` in your project root. The package integrates with Imagine, so ensure you also have `imagine/imagine` installed (v1.0.4+ recommended). No additional Laravel-specific setup is needed beyond requiring the package.
Does contao/imagine-svg support Laravel’s filesystem (Storage facade) for SVG uploads?
Yes. Use Laravel’s `Storage` facade to upload SVGs (e.g., `Storage::disk('public')->put('image.svg', $file)`), then process them with the package. The package itself doesn’t enforce filesystem rules—it works with any Imagine-compatible input stream.
Can I use this package to generate SVG thumbnails asynchronously in Laravel?
Absolutely. Dispatch a queued job (e.g., `OptimizeSvgJob`) to handle heavy SVG transformations. The package’s lightweight design makes it ideal for background processing. Pair it with Laravel’s `shouldQueue()` or Horizon for monitoring.
What Laravel versions and PHP versions does contao/imagine-svg support?
The package requires PHP 8.0+ and is framework-agnostic, but it works seamlessly with Laravel 9/10. Tested with Imagine 1.0.4+, which aligns with Laravel’s dependency ecosystem. No Laravel-specific version locks exist, but PHP 8.1+ is recommended for stability.
How does contao/imagine-svg handle malformed SVGs (e.g., invalid XML namespaces)?
Version 1.0.4 introduces XML namespace handling and graceful error suppression for invalid resize filters. Malformed SVGs may still fail, but the package now silences exceptions instead of crashing. Validate inputs with `libxml` or `ext-svg` for pre-processing.
Can I cache processed SVGs in Laravel using this package?
Yes. Cache transformed SVGs with Laravel’s cache drivers (e.g., `Cache::tags(['svg'])->put('thumbnail', $svgData, 3600)`). The package’s output is Imagine-compatible, so cached results can be reused without reprocessing.
Are there alternatives to contao/imagine-svg for SVG manipulation in Laravel?
For basic SVG handling, consider `spatie/image-optimizer` (supports SVG optimization) or `league/html-to-markdown` (for SVG-in-HTML workflows). For advanced transformations, `imagine/imagine` with `ext-gd`/`ext-imagick` is a fallback, but lacks native SVG support.
How do I test SVG transformations in Laravel’s CI pipeline?
Use PHPUnit to test SVG operations with mock files or temporary storage. Validate edge cases like complex SVGs (e.g., with `libxml` validation) or animated SVGs. The package’s new error handling reduces flakiness, but test with diverse SVG datasets to catch regressions.
Will this package work with Laravel Vapor for serverless SVG processing?
Yes, but ensure your Vapor setup includes PHP extensions like `ext-gd` or `ext-imagick` for raster fallbacks. The package’s lightweight design makes it suitable for serverless, but test cold-start performance for high-volume SVG processing.
How do I handle SVG aspect ratios or undefined sizes in Laravel?
Use the package’s `SvgBox` class to check size types: `TYPE_ABSOLUTE`, `TYPE_ASPECT_RATIO`, or `TYPE_NONE`. For undefined sizes, enforce defaults in Laravel (e.g., `config(['svg.default_width' => 800])`) or use Imagine’s `resize()` with aspect ratio constraints.
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