sixel

package module
v0.0.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 9 Imported by: 46

README

go-sixel

DRCS Sixel Encoder/Decoder for Go

Requirements

  • Go 1.24 or later
  • A sixel-compatible terminal (see Supported Terminals)
  • ffmpeg and ffprobe (only for gosvideo)

Supported Terminals

Sixel is a bitmap graphics protocol. The following terminals are known to support sixel output:

Installation

Library
go get github.com/mattn/go-sixel
Commands
go install github.com/mattn/go-sixel/cmd/gosr@latest
go install github.com/mattn/go-sixel/cmd/gosd@latest
go install github.com/mattn/go-sixel/cmd/gosgif@latest
go install github.com/mattn/go-sixel/cmd/gosvideo@latest
Command Description
gosr Image renderer
gosd Decoder to PNG
goscat Render cats
gosgif Render animation GIF
gosvideo Render video via ffmpeg
gosl Run SL

Usage

Render an image
$ gosr foo.png

Or from stdin:

$ cat foo.png | gosr -
Decode sixel to PNG
$ cat foo.drcs | gosd > foo.png
Render an animation GIF
$ gosgif nyacat.gif
Play a video
$ gosvideo movie.mp4
$ gosvideo -width 320 -fps 15 -loop clip.mp4
$ gosvideo -colors 255 -dither movie.mp4

gosvideo requires ffmpeg and ffprobe in your PATH. Default playback is tuned for speed with -colors 64 and dithering disabled.

Use as a library
img, _, _ := image.Decode(filename)
sixel.NewEncoder(os.Stdout).Encode(img)

License

MIT

Author

Yasuhiro Matsumoto (a.k.a mattn)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder decode sixel format into image

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder return new instance of Decoder

func (*Decoder) Decode

func (e *Decoder) Decode(img *image.Image) error

Decode do decoding from image

type Encoder

type Encoder struct {

	// Dither, if true, will dither the image when generating a paletted version
	// using the Floyd–Steinberg dithering algorithm.
	Dither bool

	// Width is the maximum width to draw to.
	Width int
	// Height is the maximum height to draw to.
	Height int

	// Colors sets the number of colors for the encoder to quantize if needed.
	// If the value is below 2 (e.g. the zero value), then 256 is used.
	// A color is always reserved for alpha, so 2 colors give you 1 color.
	Colors int

	// Transparent, if true, leaves the existing screen content visible
	// behind pixels with zero alpha (DECSIXEL P2=1). By default they are
	// painted in the terminal's background color (P2=0).
	Transparent bool
	// contains filtered or unexported fields
}

Encoder encode image to sixel format

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

NewEncoder return new instance of Encoder

func (*Encoder) Encode

func (e *Encoder) Encode(img image.Image) error

Encode do encoding

Directories

Path Synopsis
cmd
goscat command
gosd command
gosgif command
gosl command
gosr command
gosvideo command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL