laratusk/larasvg
| Install | |
|---|---|
composer require laratusk/larasvg |
|
| Latest Version: | v2.5.1 |
| PHP: | ^8.2 |
| License: | MIT |
| Last Updated: | Aug 5, 2026 |
| Links: | GitHub · Packagist |
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, 12.x, or 13.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.
Related Packages
Aspose.PDF Cloud is a REST API for creating and editing PDF files. It can also b...
Generate branded, scan-safe QR codes in Laravel with center logos, style templat...
PhantomMagick provides a simple API to ease the process of converting HTML to PD...