Skip to content

Adding support for 256-color and binary images #9379

@sjorskoot

Description

@sjorskoot

In #33 (comment), @kovidgoyal mentions the f=1 and f=8 format specifiers for binary images and 8-bit images respectively. I think that's a fantastic idea.

Rationale
As the image graphics protocol is getting more traction with multiple terminals adding support, we can expect more and more CLI developers implementing graphics into their applications. I'm not talking about images, but custom graphics such as interactive charts. In order to make these graphics feel native to the application, the colors should match the text colors used by the terminal. Currently is possible by querying the color scheme, but that is not viable in every scenario.

f=1
Uses 1 bit per pixel: 1 is the current foreground color and 0 is the current background color.

f=8
Uses 8 bits per pixel, or the standard 256 ANSI indices. The first 16 can be used to make colorscheme-aware graphics.

I believe adding these formats will really help making graphics first-class citizens in modern CLI applications. I'm willing to try my hand at an implementation if this is something that we want.

Image

(bonus points for whoever recognizes this)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions