hzeller / timg

A terminal image and video viewer.
GNU General Public License v2.0
1.91k stars 73 forks source link

Sixel support in foot does not get recongnized correctly #130

Closed Sivecano closed 7 months ago

Sivecano commented 8 months ago

the foot terminal supports sixel, timg does not correctly recognize this. timg does render correctly if sixel is forced by the -ps option.

hzeller commented 7 months ago

I am currently not running Wayland, so can't test. When you run the following, does the terminal print out something ?

echo -e "\033[>q"

(typically some version number and terminal name surrounded by some escape codes).

For now, you can set the TIMG_PIXELATION environment variable (see timg --help), so that you don't have to provide -ps all the time.

Sivecano commented 7 months ago

on zsh I get this image (so ^[P>|foot(1.16.2-14-g14472cdb)^[\% )

Sivecano commented 7 months ago

thanks so much :)

hzeller commented 7 months ago

Alright, added detection.

Do Videos and --grid mode look alright ? (e.g. no vertical wnadering of videos and proper vertical alignment of items in a grid). There are two slightly different flavors of what terminals implement that affect that. If things look good, nothing else needs to be done, if not (unlikely), I've to change one more thing.

Sivecano commented 7 months ago

Video will fill the terminal with the bottom most row (of 1 character height) until the video arrives at the top of the terminal. in grid mode pictures wander upwards and sometimes don't seem to reserve the correct amount of vertical space. image

hzeller commented 7 months ago

Alright, can you git pull and try again ? Hopefully that fixes the video and grid issues.

Sivecano commented 7 months ago

so... grid works but only with some numbers of columns. like 1 to 4 work, 5 exhibits the previous issues, and then 9 again. I can't even imagine why this is happening. for videos it sometimes still duplicates the bottom most line but for the most part it works as intended. it seems to depend on the specific file....

https://github.com/hzeller/timg/assets/49620143/48c8a1f3-b2f0-459e-ac04-a2e2adf90462

hzeller commented 7 months ago

I suspect the pixels where character cells are shown are not placed on integer pixel positions. Timg needs to know the characcter cell height, so that it knows how many of them to 'jump up' to show the next picture. If it reports say 10 pixels height of a character cell and the picture is 120 pixels high, then timg uses 120 / 10 = 12 characters to place the cursor to the place where the next image is to be shown. If whatever the terminal reports is different from what it internally uses to place cursors.

The terminal reports the size of the canvas and each character cell (which you see if you show a picture and add the --verbose function). Since I don't have insights with the foot terminal, maybe file a request with them to figure out ?