Skip to content

SIXEL previews fail when using the full terminal dimensions #12

Description

@r1w1s1

SIXEL previews fail with large terminal dimensions

Problem

This is related to commit c4d442e, which added SIXEL margins following PR #10.

Sorry for bringing this up again. I initially thought the margin change had fully resolved the SIXEL preview issue, but further testing with different images revealed this additional case.

The margins fixed image clipping, but I found another issue with larger terminal dimensions: some images do not render when dfm passes the full terminal size to chafa.

My setup:

  • xterm 410
  • tmux 3.7b
  • chafa 1.18.2
  • SIXEL enabled in xterm and tmux

The affected files were normal PNG and JPEG images, including screenshots with dimensions around 1366x768 and 1370x768.

The command generated by dfm used a size such as:

-s 188x43

The same images rendered correctly when limiting the size manually:

chafa --format=sixel -s 100x20 image.png

Downstream patch used for testing

I tested the following downstream SlackBuild patch successfully:

-#define DFM_IMG_CHAFA_CMD "chafa", "--format=sixel", "-s"
+#define DFM_IMG_CHAFA_CMD "chafa", "--format=sixels", "--animate=off", \
+  "--colors=256", "--dither=ordered", "--margin-bottom=1", \
+  "--margin-right=1", "-s"

The patch also limits the dimensions passed by dfm:

-str_push_u32(&p->io, p->col);
+str_push_u32(&p->io, MIN(p->col, 100));
 str_push_c(&p->io, 'x');
-str_push_u32(&p->io, p->row - 1);
+str_push_u32(&p->io, MIN(p->row - 1, 20));

With these changes, the affected PNG and JPEG images render correctly in
xterm + tmux using SIXEL output.

Workaround

Limiting the SIXEL preview size to approximately 100x20 terminal cells makes the previews work reliably.

Would it make sense for dfm to cap the SIXEL preview dimensions, or otherwise account for terminal SIXEL graphic-size limits?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions