A collection of experiments with sixel graphics
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Coffee 4c05e577fb Change links to Codeberg, update copyright line 4 months ago
screenshots Add xkcd viewer "sixkcd", with screenshots 2 years ago
LICENSE License code under AGPL-3.0-or-later 2 years ago
README.md Change links to Codeberg, update copyright line 4 months ago
bifur-bitmap.awk Change links to Codeberg, update copyright line 4 months ago
detect-font-geometry.py Change links to Codeberg, update copyright line 4 months ago
horigraph.awk Change links to Codeberg, update copyright line 4 months ago
mandelbrot-bitmap.awk Change links to Codeberg, update copyright line 4 months ago
population-bitmap.awk Change links to Codeberg, update copyright line 4 months ago
population.awk Change links to Codeberg, update copyright line 4 months ago
sixel.py Add minimal sixel generator (Python) 12 months ago
sixkcd.bash Improve comments 1 year ago
text-test.sixel Add experiment with sixel alignment relative to text 2 years ago

README.md

Sixel Experiments

A collection of experiments with sixel graphics.

What is this?

This is a collection of experiments with sixel graphics I decided to share with the world. Some things may be useful, but YMMV.

But Coffee, what on earth are sixel graphics?

👉 Did you know:

You can display actual bitmap images on the actual console in selected terminal emulators.

https://en.wikipedia.org/wiki/VT340

Observe:

graphical "this is fine" meme in an xterm

How can I display sixel graphics?

First you need a sixel-capable terminal emulator

XTerm supports this, but needs a little nudging to enable:

$ xterm -xrm "XTerm*decTerminalID: vt340" -xrm "XTerm*numColorRegisters: 256"

But do you a favor and run the following:

$ echo "XTerm*decTerminalID: vt340" >> $HOME/.Xresources
$ echo "XTerm*numColorRegisters: 256" >> $HOME/.Xresources
$ echo "XTerm*disallowedWindowOps: 1,2,3,4,5,6,7,8,9,11,13,19,20,21,GetSelection,SetSelection,SetWinLines,SetXprop" >> $HOME/.Xresources
$ xrdb $HOME/.Xresources

And all your XTerm sessions will have 256-color sixel graphics enabled by default.

(The third line sets up some exceptions so we're allowed to query XTerm about its active screen size in pixels, from which we can then calculate the character cell size, which is kind of important to know when you want to align sixel graphics with text. Other terminal emulators already allow this by default.)

The only other sixel-capable X terminal emulator offered by Debian Buster is mlterm. No special options are needed to enable sixel graphics.

See the libsixel home page for other sixel-capable terminal emulators, including ones for the framebuffer console.

Then you need some sixel graphics

  • Install libsixel-bin and use its img2sixel program to display most common image formats.
  • ImageMagick (but not GraphicsMagick!) can convert to and from sixel format.
  • All files in this repository ending in .sixel can simply be shown on the terminal with cat.
  • Working programs in this repository will emit sixel graphics, if you can figure them out.

Status

This repository is intended for experiments, and not to hold mature programs. Programs may be in various stages of completion, and various stages of documentation, including not at all.

Screenshots

population.awk:

Screenshot of population.awk

horigraph.awk:

Screenshot of horigraph.awk

population-bitmap.awk (v1):

Screenshot of population-bitmap.awk

population-bitmap.awk (v2):

Screenshot of population-bitmap.awk

bifur-bitmap.awk:

Screenshot of bifur-bitmap.awk

text-test.sixel:

Screenshot of text-test.sixel

mandelbrot-bitmap.awk showing the full mandelbrot set:

mandelbrot-bitmap.awk showing the full mandelbrot set

mandelbrot-bitmap.awk - usage - zooming in:

mandelbrot-bitmap.awk - usage - zooming in

mandelbrot-bitmap.awk showing a zoomed-in view of the mandelbrot set:

mandelbrot-bitmap.awk showing a zoomed-in view of the mandelbrot set

sixkcd.bash black-on-white:

Screenshot of sixkcd.bash showing xkcd comic 2154, black-on-white

sixkcd.bash white-on-black:

Screenshot of sixkcd.bash showing xkcd comic 2154, white-on-black

Resources

  • Sixel at Wikipedia
  • Libsixel (github): Explanations, related projects, screenshots, examples. Its helper programs such as img2sixel are available from Debian Buster package libsixel-bin. It also provides Python bindings, but sadly these aren't packaged for Buster.
  • All About SIXELs by Chris F. Chiesa.
  • VT330/340 Programmer Reference Manual Volume 2 Chapter 14: Sixel Graphics
  • "Jexer, a text windowing system that resembles Turbo Vision. The first and only text windowing system that supports mixed text and images to Xterm via sixel. Runs on Linux, Mac, and Windows. Written in Java. Feature complete."

Supplemental resources:

Author

Coffee

Contact

License

Copyright (C) 2022 by Coffee (@coffee@toot.cafe)

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

The full text of this license can be found in the file called LICENSE.

SPDX-License-Identifier: AGPL-3.0-or-later [-> link]