You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Go library for converting images to ANSI art. Renders images as colored terminal text using ASCII characters, Unicode block characters, or custom character sets. Supports static images and animated GIFs.
Demos
Unicode Half Blocks (default)
ASCII Characters
Limited Palette with Dithering
Install
go get github.com/Zebbeni/ansipx
Usage
package main
import (
"fmt""github.com/Zebbeni/ansipx"
)
funcmain() {
// Render with default settings (Unicode half-blocks, true color, fit 50x40)result, err:=ansipx.RenderFile("photo.png", ansipx.DefaultOptions())
iferr!=nil {
panic(err)
}
fmt.Print(result)
}
opts:=ansipx.DefaultOptions()
opts.OutputAlpha=true// transparent pixels render as empty spaceopts.AlphaThreshold=0.5// pixels with alpha below 0.5 are treated as transparentopts.TrimAlpha=true// crop transparent borders from outputresult, _:=ansipx.RenderFile("sprite.png", opts)
fmt.Print(result)
When alpha is enabled with Unicode block characters, partially transparent cells automatically select the best-fit block character (from the full set of quarter, half, three-quarter, and full blocks) to render only the opaque sub-pixels with foreground color while leaving the transparent portion as background.