$ show charmbracelet/freeze
Freeze is a CLI tool written in Go that generates high-quality images (PNG, SVG, WebP) of source code or terminal output. It uses syntax highlighting via Chroma, supports ANSI escape sequence rendering, and provides extensive customization options including themes, fonts, shadows, borders, and interactive configuration via a TUI. The architecture is a single binary with a well-structured codebase: main.go orchestrates parsing, lexing, and rendering; config.go handles configuration loading from JSON files or flags; ansi.go implements a custom ANSI dispatcher to build SVG text elements; svg/svg.go provides reusable SVG decoration helpers. The tool can execute shell commands and capture their output for screenshots. It follows modern Go practices, has comprehensive golden-file tests, and is actively maintained by Charmbracelet. The code is highly modular and contains several components that could be reused independently, such as the ANSI dispatcher and SVG manipulation utilities.
The LLM identified 3 files worth highlighting for reuse:
Provides a clean API for adding SVG decorations (shadow, clip path, corner radius, window controls) to an existing SVG element. It is fully isolated from the rest of the project and can be reused in any Go project that needs to programmatically modify SVG documents.
Implements a dispatcher that handles ANSI escape sequences and builds SVG text elements with proper styling (colors, bold, italic, background). The pattern is a clean separation of ANSI parsing from rendering, making it reusable for any project that needs to parse ANSI to SVG or other formats. It uses the charmbracelet/x/ansi library for parsing.
A simple utility to slice input lines by line numbers, supporting negative indexing and single line selection. It is well-tested, self-contained, and can be extracted to any Go project needing line-range operations.