Hi,
timg (
http://timg.sh/ ) is an image and video viewer for terminals with a bunch of useful features to show images in a terminal. For simple terminals, it uses block characters to show images. If a terminal supports the iTerm2 or Kitty image protocols it can use that to show high-resolution images.
I just read somewhere that hterm also supports the iTerm2 protocol; so now I made timg also work with hterm :)
I had to do some work-arounds for limitations [1], but overall, it is pretty promising.
To use you have to supply the -pi option to timg to output an image using the high-res iTerm2 mode:
timg -pi some-image.jpgNot all features of timg work due to limitations of hterm, but I hope they might be implemented in the future ? Some look potentially easy to implement:
- Placing images only seems to work on the left of the terminal window. Moving the cursor to a different character cell to the right before showing an image will still only show the image flush to the left. This means that timg --center and --grid features don't work.
- To play animations and videos, timg would need to know the size of a character cell in pixels. For that, it uses a TIOCGWINSZ ioctl. Alas, the window size in pixels is not returned. Animations and videos still work in the regular Unicode block modes though (using -pq), just not in high resolution iTerm2 image mode.
- The terminal can not be queried with the somewhat common \033[>q CSI, so timg can not auto-detect if the terminal likely supports iTerm2 graphics. The user has to provide -pi option ( or long --pixelation=iterm2).
Question to the developers: is there a reliable way for a program to figure out if it runs in a hterm ?
In general this is already exciting. I often inspect images on a remote server on the shell with timg, and this is another terminal emulator that I can use now :)
Thanks to the hterm team to support the high-resolution image feature.