atelier / rasterizer
Rasterize SVG documents to bitmaps through external rendering adapters (resvg, rsvg-convert)
Fund package maintenance!
Requires
- php: >=8.3
- psr/log: ^3.0
- symfony/process: ^7.3|^8.0
Requires (Dev)
- atelier/svg: ^1.0
- friendsofphp/php-cs-fixer: ^3.94
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12.5
- rector/rector: ^2.3
Suggests
- atelier/svg: Build SVG documents in PHP; any Stringable SVG is accepted as input.
- librsvg2-bin: Provides the rsvg-convert binary used by RsvgConvertRasterizer.
- resvg/resvg: Provides the resvg binary used by ResvgRasterizer.
This package is auto-updated.
Last update: 2026-08-08 00:49:51 UTC
README
Rasterize SVG documents to bitmaps through external rendering adapters
(resvg, rsvg-convert). A typed PHP abstraction over a rasterizer binary; it
does not render SVG in PHP itself.
Install
composer require atelier/rasterizer
Requires PHP 8.3+, symfony/process, psr/log, and one rasterizer binary on
the host (resvg or rsvg-convert).
# macOS brew install resvg # Debian / Ubuntu apt install librsvg2-bin
See Installation for other platforms, package-source links, and binary licenses.
Example
use Atelier\Rasterizer\Bitmap\BitmapOptions; use Atelier\Rasterizer\Rasterizer; $rasterizer = Rasterizer::create(); $bitmap = $rasterizer->rasterize($svg, new BitmapOptions( width: 1200, height: 630, keepAspectRatio: true, )); $bitmap->save('card.png');
$svg is a markup string, any \Stringable (such as an Atelier\Svg\Svg
document), or an SvgInput built from a file or stream. keepAspectRatio is
enabled by default, so giving both width and height fits the SVG inside that
box where the selected adapter supports it.
Rasterizer::create() picks the first available adapter in package order
(resvg, then rsvg-convert). For reproducible production output, you can
also select an adapter explicitly:
$rasterizer = Rasterizer::resvg(); $rasterizer = Rasterizer::rsvgConvert();
Documentation
License
MIT