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:
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?
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
dfmpasses the full terminal size tochafa.My setup:
The affected files were normal PNG and JPEG images, including screenshots with dimensions around 1366x768 and 1370x768.
The command generated by
dfmused a size such as:The same images rendered correctly when limiting the size manually:
Downstream patch used for testing
I tested the following downstream SlackBuild patch successfully:
The patch also limits the dimensions passed by
dfm: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
100x20terminal cells makes the previews work reliably.Would it make sense for
dfmto cap the SIXEL preview dimensions, or otherwise account for terminal SIXEL graphic-size limits?