atelier/rasterizer

Rasterize SVG documents to bitmaps through external rendering adapters (resvg, rsvg-convert)

Maintainers

Package info

github.com/ateliersvg/rasterizer

pkg:composer/atelier/rasterizer

Transparency log

Fund package maintenance!

smnandre

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.7.0 2026-08-07 23:57 UTC

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