The Kitty protocol starts with multiple formats:
>> The terminal emulator must understand pixel data in three formats, 24-bit RGB, 32-bit RGBA and PNG.
Different tools for different needs, but if you are going for a wide support you want something simple that doesn't also have 5 different types you have to separately implement and test:
>> d: Direct (the data is transmitted within the escape code itself)
>> f: A simple file (regular files only, not named pipes or similar)
>> t: A temporary file, the terminal emulator will delete the file after reading the pixel data. For security reasons the terminal emulator should only delete the file if it is in a known temporary directory, such as /tmp, /dev/shm, TMPDIR env var if present and any platform specific temporary directories and the file has the string tty-graphics-protocol in its full file path.
>> s: A shared memory object, which on POSIX systems is a POSIX shared memory object and on Windows is a Named shared memory object. The terminal emulator must read the data from the memory object and then unlink and close it on POSIX and just close it on Windows.
> What nonsense, it takes literally 15 lines of code without using anything beyond the standard library to write a client
Conveniently taking a preencoded PNG and assuming away the necessary queries of supported protocol:
>> Since a client has no a-priori knowledge of whether it shares a filesystem/shared memory with the terminal emulator, it can send an id with the control data, using the i key (which can be an arbitrary positive integer up to 4294967295, it must not be zero).
> I challenge you to match that for sixel
Challenge accepted. There are many libraries for many languages. Let's look at this one in perl:
https://github.com/saitoha/libsixel/tree/master/perl
use Image::LibSIXEL;
$encoder = Image::LibSIXEL::Encoder->new();
$encoder->setopt("w", 400);
$encoder->setopt("p", 16);
$encoder->encode("images/egret.jpg");
and some print($encoder) to print the output, and this works on all the terminals listed on https://www.arewesixelyet.com/Compared to kitty: "As of April 2022, kitty and WezTerm are the only terminal emulators to support this graphics protocol completely, with Konsole and wayst having partial support"
There are many nice things about the kitty protocol, but I think it's ultimately too complicated for the task. It's a Homer Mobile: https://www.wired.com/2014/07/homer-simpson-car/
If we want graphics in the terminal, first we need graphics in the terminal (using sixels is the simplest way, and you get access to many tools) then you can do more if you still want to - but you're likely to realize by then that all the extra things Kitty supports is YAGNI: https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it?use...