laratusk / larasvg
A modern Laravel package for SVG conversion with multiple provider support (Resvg, Inkscape, rsvg-convert). Convert SVG to PNG, PDF, EPS, and more.
v2.2.0
2026-02-15 22:07 UTC
Requires
- php: ^8.2
- illuminate/contracts: ^10.0|^11.0|^12.0
- illuminate/filesystem: ^10.0|^11.0|^12.0
- illuminate/process: ^10.0|^11.0|^12.0
- illuminate/support: ^10.0|^11.0|^12.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.0|^3.0
- laravel/pint: ^1.0
- orchestra/testbench: ^8.0|^9.0|^10.0
- phpunit/phpunit: ^10.5|^11.0
- rector/rector: ^2.0
This package is auto-updated.
Last update: 2026-02-16 06:16:38 UTC
README
A modern Laravel package for SVG conversion with multiple provider support. Convert SVG files to PNG, PDF, EPS, and more using a fluent API and Laravel's Process facade.
Battle-Tested
Backed by over 80 million SVG-to-format conversions in production across three years, this codebase is truly battle-tested. Releasing it as a package was the logical evolution.
Requirements
- PHP 8.2+
- Laravel 10.x, 11.x, or 12.x
- At least one converter installed:
- Resvg — recommended for PNG
- Inkscape 1.0+ — for PDF, EPS, PS, EMF, WMF
- rsvg-convert — lightweight, PNG/PDF/PS/EPS/SVG
- CairoSVG — Python-based, PNG/PDF/PS/SVG
Quick Install
composer require laratusk/larasvg php artisan larasvg:setup
Documentation
Visit the full documentation for detailed guides, usage examples, API reference, and more.
Features
- Multi-provider architecture — Switch between Resvg, Inkscape, rsvg-convert, and CairoSVG with a single method call
- Resvg (default) — Lightning-fast SVG to PNG conversion
- Inkscape — Full-featured SVG conversion to PNG, PDF, PS, EPS, EMF, WMF
- rsvg-convert — Lightweight librsvg tool for PNG, PDF, PS, EPS, and SVG output
- CairoSVG — Python-based converter using the Cairo 2D library; PNG, PDF, PS, SVG
- Custom drivers — Register your own converter via config or
SvgConverter::extend()— no package code changes needed - Fluent API — Chainable methods for dimensions, background, format, and provider-specific options
- Laravel Filesystem — Read from and write to any Laravel disk (S3, local, etc.)
- Stdout output — Pipe conversion output directly to stdout for streaming responses
- Facade — Clean
SvgConverter::static API with IDE autocompletion - Testable — Built on Laravel's Process facade with full
Process::fake()support - Setup command — Interactive
php artisan larasvg:setupto detect and install providers
Supported Formats
| Format | Resvg | Inkscape | rsvg-convert | CairoSVG |
|---|---|---|---|---|
| PNG | Yes | Yes | Yes | Yes |
| — | Yes | Yes | Yes | |
| SVG | — | Yes | Yes | Yes |
| PS | — | Yes | Yes | Yes |
| EPS | — | Yes | Yes | — |
| EMF | — | Yes | — | — |
| WMF | — | Yes | — | — |
Quick Start
use Laratusk\Larasvg\Facades\SvgConverter; // Default provider (Resvg) SvgConverter::open(resource_path('svg/file.svg')) ->setFormat('png') ->setDimensions(1024, 1024) ->toFile(storage_path('app/output.png')); // Switch provider per call SvgConverter::using('inkscape') ->open(resource_path('svg/file.svg')) ->setFormat('pdf') ->toFile(storage_path('app/output.pdf')); SvgConverter::using('cairosvg') ->open(resource_path('svg/file.svg')) ->setFormat('pdf') ->setScale(2.0) ->toFile(storage_path('app/output.pdf'));
Contributing
Please see CONTRIBUTING.md for details.
License
MIT License. See LICENSE for details.
