From 9bf686f48e4dfcc64c4c9434a63989316f520dba Mon Sep 17 00:00:00 2001 From: cashmere Date: Sun, 26 Apr 2026 20:52:19 +0200 Subject: feat(sixel): configurable encoder + per-invocation timeout Sixel encoding was hard-coded to ImageMagick (`magick'/`convert') with no timeout, so a malformed image or hung encoder could freeze Emacs and users could not switch to libsixel's faster `img2sixel'. - New customs: `kitty-gfx-sixel-encoder-program' (nil = auto-detect: prefer img2sixel, then magick, then convert), `-encoder-args' (extra args list), `-encoder-timeout' (float seconds, default 5.0, nil = no timeout). - New helper `kitty-gfx--sixel-resolve-encoder' returns (KIND . ABS-PATH) where KIND is `img2sixel' or `imagemagick' so the encode pipeline can build the right argv (`-w/-h ' vs `-geometry WxH sixel:-'). - New helper `kitty-gfx--sixel-run-encoder' runs the encoder via `make-process' with a separate stderr buffer and a `run-at-time' watchdog that kills the process on timeout; failures and timeouts are logged and surface as nil from `kitty-gfx--sixel-encode' rather than freezing Emacs. - Existing magick/convert path preserved and still chosen automatically when img2sixel is absent. - AGENTS.md: dependency note updated to mention img2sixel and the new customs. Inspired by and co-authored with @timfel's sixel-graphics.el fork (https://github.com/timfel/sixel-graphics.el), which introduced the configurable encoder + timeout pattern. Refs #4. Co-authored-by: Tim Felgentreff --- AGENTS.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'AGENTS.md') diff --git a/AGENTS.md b/AGENTS.md index e5c07a6..ccd185f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -265,7 +265,10 @@ Key design differences from images: - **Required**: Emacs >= 27.1, a supported terminal (Kitty/WezTerm/Ghostty for Kitty backend; foot/Konsole/xterm/mlterm/mintty for Sixel) -- **Required for Sixel**: ImageMagick (`magick`/`convert`) for encoding +- **Required for Sixel**: a Sixel encoder on PATH -- `img2sixel` + (libsixel, recommended) or ImageMagick (`magick`/`convert`). + Override via `kitty-gfx-sixel-encoder-program'; bound by + `kitty-gfx-sixel-encoder-timeout' (default 5s). - **Optional for Kitty**: ImageMagick for non-PNG formats and pixel-accurate sizing - **Optional for typst preview**: `typst` CLI on PATH (used by `kitty-gfx-typst-preview`) -- cgit v1.3.1