Merged
Conversation
Contributor
Author
|
Demo how you can play gif using textual serve in your browser Screen.Recording.2026-03-30.181124.mp4 |
Owner
|
That's impressive. Happy to merge the PR once the conflict is resolved. |
92bc6f8 to
95e176b
Compare
Contributor
Author
|
Hi @lnqs, I update PR, I used https://github.com/saitoha/libsixel as ref to see what are best ways to optimize sixel encoding. |
ae90c03 to
a7d93b3
Compare
Contributor
Author
|
Update PR again to fix all lint errors |
a7d93b3 to
baef9c8
Compare
Contributor
Author
|
Now it's green ✅ |
Owner
|
Merge and release are on the way, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sixel Encoding Optimization
Reworked sixel encoding to reduce output size and improve end-to-end terminal rendering performance.
Most of the core compression and emission ideas in this rewrite were adapted from libsixel, with a Python implementation and an optional NumPy-accelerated fast path.
All encoder settings are now grouped in a
SixelOptionsdataclass for a clean API that is easy to extend.Encoding speed
Benchmarks were run on two groups of animated image frames:
On the larger HD-style set, the new encoder is typically faster while also producing much smaller output:
Representative results from the larger HD-style set:
Output size reduction
The biggest win is output size, which directly reduces the amount of sixel data written over the PTY.
Representative results from the larger HD-style set:
Key optimizations
Band-based encoding — Processes full 6-row sixel bands at once instead of encoding row-by-row.
Interleaved segment emission — Emits non-overlapping color segments in shared sweeps, reducing redundant carriage returns and padding.
Fillable first sweep — Uses a libsixel-style fill pass that compresses especially well with RLE.
Gap splitting — Large empty gaps are split into separate segments instead of being bridged with excessive
?padding.Palette compaction — Deduplicates colors that map to the same sixel RGB values and reorders palette entries for smaller output.
Active color reuse — Avoids re-emitting color-select commands when the same color is already active.
NumPy vectorized path — Adds an accelerated path for band packing with a pure-Python fallback.