PHP port of charmbracelet/freeze โ
turn code or terminal output into an SVG screenshot. No ext-gd /
Imagick required; the output is plain text suitable for git diffs and
CI artifacts.
composer require candycore/candy-freezeecho "function hello() { return 'world'; }" \
| candyfreeze --theme dracula --line-numbers > out.svg
candyfreeze input.php \
--theme tokyo-night --no-window --output screenshot.svgFlags:
--theme {dark|light|dracula|tokyo-night|nord}โ colour palette.--padding Nโ content padding inside the frame.--no-windowโ drop the macOS-style traffic-light controls.--no-shadowโ drop the SVG drop-shadow filter.--no-borderโ drop the frame outline.--line-numbersโ render a left-gutter line counter.--border-radius Nโ corner radius of the frame.-o/--output <path>โ write SVG to a file instead of stdout.
use CandyCore\Freeze\SvgRenderer;
$svg = SvgRenderer::dracula()
->withLineNumbers(true)
->withWindow(true)
->withPadding(24)
->render($code);
file_put_contents('out.svg', $svg);ANSI input is honoured โ SGR foreground colours (16 / 256 / 24-bit truecolor)
plus bold / italic / underline become <tspan> segments in the output.
$svg = SvgRenderer::dark()->render("\x1b[31merror:\x1b[0m something broke");SvgRenderer::dark(); // charm-ish #0d1117
SvgRenderer::light(); // #f6f8fa
SvgRenderer::dracula(); // #282a36
SvgRenderer::tokyoNight(); // #1a1b26
SvgRenderer::nord(); // #2e3440Build a custom theme via the Theme constructor โ set background / foreground
/ border / shadow / line-number colour / window-control colours / font family
/ size / line height.
cd candy-freeze && composer install && vendor/bin/phpunit