pg_aa
pg_aa · ASCII art extension for PostgreSQL
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100577 | pg_aa | pg_aa | 1.0 | FUNC | PostgreSQL | C |
Usage
Sources:
pg_aa converts a PNG image stored as bytea into text art inside PostgreSQL. It exposes one monochrome ASCII renderer backed by aalib and one UTF-8 renderer backed by libcaca; it is a demonstration extension, not an image-storage or document-processing system.
Core Workflow
Store the raw PNG bytes in a table or bind them as a query parameter, then choose an output width:
The output height is derived from the source aspect ratio and the requested width, with an adjustment for terminal character proportions.
Function Index
aa_out(bytea, int4)returns newline-separated, locale-independent ASCII using aalib.caca_out(bytea, int4)returns libcaca’s UTF-8 text rendering.
Both functions are immutable and strict. Input must be a decodable PNG; other formats raise an error.
Operational Boundaries
The server binary must link compatible versions of libgd, aalib, and libcaca. Decode and raster processing happen synchronously in the database backend, so restrict image size and output width to prevent excessive CPU or memory consumption. The reviewed source dates from 2015 and has no README, declared compatibility matrix, or size guards; test malformed PNGs, zero/negative widths, extreme aspect ratios, Unicode client encodings, library upgrades, and parallel use before exposing either function to untrusted callers.