Blizzaga

Generate images of code and terminal output.
This fork of freeze adds the
srcery theme and sets it as the default.
Examples
Blizzaga generates PNGs, SVGs, and WebPs of code and terminal output alike.
Generate an image of code
blizzaga artichoke.hs -o artichoke.png
Generate an image of terminal output
You can use blizzaga to capture ANSI output of a terminal command with the --execute flag.
blizzaga --execute "eza -lah"
Blizzaga is also super customizable and ships with an
interactive TUI.
Installation
Install with Go:
go install github.com/starbaser/blizzaga@latest
Run with Nix:
nix run github:starbaser/blizzaga
From a local checkout:
nix run '.#'
nix develop -c go run .
Customization
Interactive mode
Blizzaga features a fully interactive mode for easy customization.
blizzaga --interactive
Settings are written to $XDG_CONFIG/blizzaga/user.json and can be accessed with
blizzaga --config user.
Flags
Screenshots can be customized with --flags or Configuration files.
[!NOTE]
You can view all blizzaga customization with blizzaga --help.
-b, --background: Apply a background fill.
-c, --config: Base configuration file or template.
-l, --language: Language to apply to code
-m, --margin: Apply margin to the window.
-o, --output: Output location for .svg, .png, .jpg.
-p, --padding: Apply padding to the code.
-r, --border.radius: Corner radius of window.
-t, --theme: Theme to use for syntax highlighting.
-w, --window: Display window controls.
-H, --height: Height of terminal window.
--border.width: Border width thickness.
--border.color: Border color.
--shadow.blur: Shadow Gaussian Blur.
--shadow.x: Shadow offset x coordinate.
--shadow.y: Shadow offset y coordinate.
--font.family: Font family to use for code.
--font.ligatures: Use ligatures in the font.
--font.size: Font size to use for code.
--font.file: File path to the font to use (embedded in the SVG).
--line-height: Line height relative to font size.
--show-line-numbers: Show line numbers.
--lines: Lines to capture (start,end).
Language
If possible, blizzaga auto-detects the language from the file name or analyzing the file contents.
Override this inference with the --language flag.
Go, BAML, and injected FML source are highlighted by statically linked Tree-sitter grammars. Their
syntax trees and highlight queries are translated into Chroma tokens, so they use the same themes
and SVG formatter as every other language. Every BAML raw string (#"..."#) is parsed with the
FML grammar: its prose stays string content while Jinja markers, directives, expressions, and FML
tags inside it are highlighted, matching the ${ } treatment of backtick strings. A raw-string
function tail whose declared return type is filament.Template is instead full FML markup. BAML and FML
use the first-party grammar pinned by Blizzaga's Nix flake. Its BAML highlight query is embedded in
the same Go module as the parser; Blizzaga appends only its local styling overrides and injection
queries. Updating the grammar pin therefore updates the parser and canonical highlights together.
The remaining languages continue to use Chroma's built-in lexers.
FCSS uses Chroma's CSS lexer through either --language fcss or an .fcss filename. An explicit
unknown language selects Chroma's plain-text fallback; it does not silently reinterpret the
language from a filename or the source contents.
cat artichoke.hs | blizzaga --language haskell
Reusing the highlighter
The public highlight package returns
the exact source plus neutral, byte-addressed token classifications. It does not apply a theme or
put ANSI into the source. highlight.Highlight is the one-shot entry point; editable documents use
Registry.NewSession, Session.ApplyEdit, and Session.Close to retain and incrementally update
the native parser and syntax tree. Chroma-backed sessions re-lex after an edit but use the same
exact-source result contract.
result, err := highlight.Highlight(source, highlight.Query{Language: "go"})
// result.Source is byte-for-byte source; result.Spans carries classifications.
highlight.SrceryStyle() exposes the CLI's base Chroma style for other renderers.
Adding a Tree-sitter language
Tree-sitter support is intentionally a Blizzaga integration rather than a Chroma fork. Construct a
validated, frozen registry with highlight.NewRegistry, passing highlight.Language descriptors
that carry the statically linked grammar, aliases, highlight query, and capture map. Registered
Tree-sitter languages take precedence over Chroma's complete fallback catalog. A descriptor can
also register validated highlight.Injection queries, whose byte ranges own retained child parsers
and syntax trees that are closed with the parent session.
To add another statically linked language:
- Add the grammar's Go binding to
go.mod.
- Embed its highlight query beside the registry construction.
- Start with
highlight.StandardCaptures() and add grammar-specific capture mappings.
- Pass the descriptor to
highlight.NewRegistry before creating a document session.
Highlight queries may use Tree-sitter's built-in text predicates and the priority setting.
Unsupported property predicates, custom predicates, and other settings fail during registry
construction rather than being ignored. An highlight.Injection can select another registered
grammar for @injection.content; injected spans are rebased to the parent source and owned by the
same session lifecycle. Grammar bindings use cgo and are compiled into the consumer; runtime-loaded
parser plug-ins are not part of this contract.
Theme
The default theme is srcery. Change the color theme with --theme; the original charm theme
remains available.
blizzaga artichoke.hs --theme srcery
Output
Change the output file location, defaults to out.svg or stdout if piped.
This value supports .svg, .png, .webp.
blizzaga main.go --output out.svg
blizzaga main.go --output out.png
blizzaga main.go --output out.webp
# or all of the above
blizzaga main.go --output out.{svg,png,webp}
Font
Specify the font family, font size, and font line height of the output image.
Defaults to bundled Iosevka Custom, 16 px, 1.25 em. The bundled font's
measured column advance is 0.5 em and its line pitch is 1.25 em, so this
default produces an 8 × 20 pixel terminal cell with its natural 2.5:1
height-to-width ratio and whole-pixel spacing on both axes. Font metrics determine
the proportions, not a unique preferred size; 16 px is the selected capture
default. It corresponds to 12 pt at a 96-DPI reference. Explicit font sizes
remain in pixels and may be fractional.
blizzaga artichoke.hs \
--font.family "SF Mono" \
--font.size 16 \
--line-height 1.4
Installed family names resolve through Fontconfig to actual regular, bold, italic, and bold italic
font files. An unavailable named family is an error. Use --font.file to select a TTF, OTF, WOFF, or WOFF2 file;
its actual family name is authoritative, and matching sibling faces are loaded from its directory.
The chosen bytes and their design metrics are shared by SVG and raster output; fallback glyphs use
installed fonts. Web fonts are decoded into SFNT bytes, and font collections are projected to their selected
standalone face before embedding.
Fontconfig collection members, named variable instances, and explicit axis settings
remain part of the resolved face identity. Variable faces are pinned to that selection
with HarfBuzz before metrics, SVG embedding, or raster rendering; repeated fallback
glyphs reuse the retained face rather than registering it again.
Terminal-grid raster output uses a persistent glyph renderer with CPU composition and wgpu GPU
composition. The default raster_backend is auto; cpu selects CPU rendering and gpu requires
an available hardware adapter. wgpu probes Vulkan, Metal, DX12, and GLES where enabled for the
platform, trying alternate adapters when initialization fails. Automatic selection falls back to
CPU if no hardware adapter initializes or if rendering later fails; explicit gpu reports the
failure. CUDA is not required. The selected font bytes and style/fallback
faces are retained by the session. Both compositors retain unchanged pixel-row bands; the GPU
keeps a bounded glyph atlas. Equal adjacent cell backgrounds share native draw commands.
Box-drawing glyphs retain continuous font coordinates, and adjoining outlines with matching
paint share a raster coverage mask across fractional cell joins. Disjoint colors remain independent;
intersecting layers preserve their ordered source-over composition.
Opaque pixels copy directly while translucent glyph coverage retains exact composition rounding.
Rounded clip interiors use opaque blits, with masking confined to
antialiased edges. Dynamic labels render only their measured glyph ink and blend at its original
position, with separate text caches. Arbitrary SVG rasterization and cached window decoration use native resvg.
Identical terminal commands reuse completed pixels without preparing the scene again. ASCII cell
runs batch native preparation while preserving independent shaping when ligatures are disabled.
CPU canvases are bounded by the native coordinate range and a 64 Mi-pixel storage
budget. GPU texture dimensions and aligned readback capacity are checked against the
selected device; automatic rendering falls back to CPU for supported canvases that
exceed those GPU capabilities. Explicit GPU selection reports the capability error.
The native dependencies are resvg, Fontconfig, HarfBuzz's subset library, the WOFF2
codec, the blizzaga_pixels library built from the Rust crate, and pkg-config.
The Nix package and development shell supply them.
Consumers use lib.<system>.renderBuildInputs and renderNativeBuildInputs from this flake.
Entering the development shell from the repository root generates an ignored Go workspace
with the flake-pinned Tree-sitter source. Go tools discover it locally; standard-library
probes do not inherit module-only replacement flags.
To use ligatures in the font, you can apply the --font.ligatures flag.
Rendering terminal frames
The public render package accepts a
row-major render.Grid of grapheme cells with declared widths, terminal attributes, a cursor,
content-relative pixel image layers, frame time, and an optional label. Create one Session per
capture and call Render for owned premultiplied RGBA pixels, or SVG for the same self-contained
scene. Close releases the pixel compositor, Fontconfig and native resvg resources. Calls are
serialized, and context cancellation is checked around native rendering.
Session.Geometry() returns cell width, cell height, and baseline in pixels. Dimensions measures
a grid canvas for a fixed video encoder size. Baselines reserve the actual font's ascent and descent,
including on the bottom row. Config.NoChrome renders the grid without window decoration.
Grid.LabelFontSize sets an optional label size independently of cell geometry.
NewImage copies source pixels and takes content-relative pixel bounds, a source-pixel crop, and
Z order; negative Z sits below text. SVG embeds image resources; raster frames composite their raw
pixels directly without a PNG intermediate.
Line Numbers
Show line numbers in the terminal window with the --show-line-numbers flag.
blizzaga artichoke.hs --show-line-numbers
To capture only a specific range of line numbers you can use the --lines flag.
blizzaga artichoke.hs --show-line-numbers --lines 2,3
Border Radius
Add rounded corners to the terminal.
blizzaga artichoke.hs --border.radius 8
Window
Add window controls to the terminal, macOS-style.
blizzaga artichoke.hs --window
Background
Set the background color of the terminal window.
blizzaga artichoke.hs --background "#121110"
Height
Set the height of the terminal window.
blizzaga artichoke.hs --height 400
Border Width
Add a border outline to the terminal window.
blizzaga artichoke.hs --border.width 1 --border.color "#515151" --border.radius 8
Padding
Add padding to the terminal window.
You can provide 1, 2, or 4 values.
blizzaga main.go --padding 20 # all sides
blizzaga main.go --padding 20,40 # vertical, horizontal
blizzaga main.go --padding 20,60,20,40 # top, right, bottom, left
Margin
Add margin to the terminal window.
You can provide 1, 2, or 4 values.
blizzaga main.go --margin 20 # all sides
blizzaga main.go --margin 20,40 # vertical, horizontal
blizzaga main.go --margin 20,60,20,40 # top, right, bottom, left
Shadow
Add a shadow under the terminal window.
blizzaga artichoke.hs --shadow.blur 20 --shadow.x 0 --shadow.y 10
Screenshot TUIs
Use tmux capture-pane to generate screenshots of TUIs.
Run your TUI in tmux and get it to the state you want to capture.
Next, use capture-pane to capture the pane and pipe that to blizzaga.
hx # in a separate pane
tmux capture-pane -pet 1 | blizzaga -c full
Configuration
Blizzaga also supports configuration via a JSON file which can be passed with the --config / -c
flag. In general, all --flag options map directly to keys and values in the config file
There are also some default configurations built into blizzaga which can be passed by name.
base: Simple screenshot of code.
full: macOS-like screenshot.
user: Uses ~/.config/blizzaga/user.json.
If you use --interactive mode, a configuration file will be created for you at
~/.config/blizzaga/user.json. This will be the default configuration file used in your
screenshots.
blizzaga -c base main.go
blizzaga -c full main.go
blizzaga -c user main.go # alias for ~/.config/blizzaga/user.json
blizzaga -c ./custom.json main.go
Here’s what an example configuration looks like:
{
"window": false,
"theme": "srcery",
"background": "#121110",
"border": {
"radius": 0,
"width": 0,
"color": "#504D47"
},
"shadow": false,
"padding": [20, 40, 20, 20],
"margin": "0",
"font": {
"family": "JetBrains Mono",
"size": 14
},
"line_height": 1.2
}
Contributing
See contributing.
Feedback
Open issues and pull requests on GitHub.
License
MIT