:: krowemoh

Thursday | 26 DEC 2024
Posts Links Other About Now

previous
next

Notes on Sixel

2024-11-04

Sixel is a graphics format that terminals can display. It uses special escape sequences to communicate to the terminal emulator which will then handle the image display aspect.

Sixel Wikipedia Page

This way you can display images right in the terminal window which is pretty crazy. I have always wanted to make a comic book viewer but I got hung up on either making a GUI application and learning how to create GUIs or using web technologies and needing to set up a server to maintain it. This opens the door to writing the type of applications I like which is a straight terminal application and it uses some very simple linux commands to do the complex stuff. I love it.

libsixel provides the img2sixel tool which is a command line tool to convert a regular image to the sixel format. As long as the terminal understands the sixel format, it will display the image right in the terminal.

You can check if your emulator supports sixel by going to Are We Sixel Yet.

I had to build libsixel so I'll outline the steps here: (it is very simple)

git clone https://github.com/saitoha/libsixel.git
cd libsixel
./configure --with-libcurl
make
sudo make install

Voila! With that we can use img2sixel with local and remote images.

img2sixel -p 16 some_image.png

-p let's you control how many colors to use, the default is 256 and here I've set it to 16. You can also control the height by using -h.

I've already got the basics of my comic book viewer working. I save the sixel data so that I don't have to keep calling img2sixel and this makes everything blazingly fast.

Sixel feels super magical because I've never thought about having images directly in my terminal. I've seen it floating around before but never played with it till now and now I feel like I've missed something major!