Skip to content

Fit-to-screen image scaling (v0.3.0)#2

Merged
whallil merged 1 commit into
mainfrom
feature/v0.3.0-fit-to-screen
May 30, 2026
Merged

Fit-to-screen image scaling (v0.3.0)#2
whallil merged 1 commit into
mainfrom
feature/v0.3.0-fit-to-screen

Conversation

@whallil

@whallil whallil commented May 30, 2026

Copy link
Copy Markdown
Owner

Summary

Adds fit-to-screen scaling so images (and Mermaid diagrams) larger than the terminal are downscaled to fit instead of overflowing onto following text.

  • Replaces image_rows() (reserve-only, height capped at terminal height → oversized images overflowed) with placement_cells(), which returns a concrete (cols, rows) box.
  • show.py passes that box as Kitty's c=/r= placement keys, so Kitty does the resampling, preserving aspect ratio. Images that already fit render pixel-for-pixel.
  • Vertical fit reserves DRIFT_MARGIN + 2 rows of headroom so a downscaled image plus its anchor offset stay on one screen (no clipped bottom).
  • Drops the leading PTY newline (was an uncommitted top gap).
  • Applies to Mermaid too, since mermaid.py displays through show.py.

Docs

  • SKILL.md: documents fit-to-screen; replaces the obsolete "taller than screen overflows / not implemented" caveat; adds an honest "vertical placement is approximate" note; adds guidance to keep inline Mermaid diagrams compact (graph LR, few nodes) since tall ones get scaled and can wash out.
  • README.md "Known limitations" updated.
  • CHANGELOG.md [0.3.0]; plugin.json0.3.0.

Testing

  • placement_cells() verified both branches: small 240×120 → native (24,6) (no scaling); tall 400×2970 → scaled (11,36), aspect preserved.
  • End-to-end renders confirmed in a live Kitty session: a photo that previously overflowed (43 unscaled rows) now scales to 36 and fits; Mermaid diagram rendered locally (mermaid-cli + Chrome) and displayed.
  • Visual placement confirmed by the maintainer.

Note

The Unicode-placeholder placement approach explored in a worktree was abandoned: the editor filters U+10EEEE (PUA) characters out of stdout, so it never renders. This PR keeps the working direct-paint path and grafts on only the resize logic. Worktree purged.

Replace image_rows() (reserve-only, height capped at the terminal
height, which let oversized images overflow onto following text) with
placement_cells(), which returns a concrete (cols, rows) box. show.py
passes it as Kitty's c=/r= placement keys so Kitty downscales the image
to fit the viewport, preserving aspect ratio. Images that already fit
are rendered pixel-for-pixel. The vertical fit reserves DRIFT_MARGIN + 2
rows of headroom so a downscaled image plus its anchor offset stay on
one screen instead of clipping at the bottom. Also drop the leading PTY
newline, which only added an uncommitted top gap.

This also applies to Mermaid diagrams, since mermaid.py displays through
show.py. Docs (SKILL.md, README, CHANGELOG) updated accordingly.
@whallil
whallil force-pushed the feature/v0.3.0-fit-to-screen branch from 0d88149 to 9dd09ad Compare May 30, 2026 21:06
@whallil
whallil merged commit b7696fd into main May 30, 2026
2 checks passed
@whallil
whallil deleted the feature/v0.3.0-fit-to-screen branch May 30, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant