Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add sixel to ansi package #380

Merged
merged 43 commits into from
Feb 21, 2025
Merged

feat: add sixel to ansi package #380

merged 43 commits into from
Feb 21, 2025

Conversation

raphamorim
Copy link
Member

@raphamorim raphamorim commented Feb 19, 2025

PR originally implemented by @CannibalVox

Ref: #352

Most of this PR changes are just updates on the implementation per requests.

API

Here's what the API looks like.

import  "github.com/charmbracelet/x/ansi/sixel"

var (
    buf bytes.Buffer
    e sixel.Encoder
    img image.Image // imagine this is populated with image data
)


if err := e.Encode(&buf, img); err != nil {
	return 0, err
}

_, _ = io.WriteString(os.Stdout, ansi.SixelGraphics(0, 1, 0, buf.Bytes()))

Example

cd examples/img2term && go run . ./../../ansi/fixtures/graphics/JigokudaniMonkeyPark.png

Screenshot 2025-02-21 at 14 21 22

Misc

Example while running go bench with fmt.Println iterm2/wezterm/rio:

image

@raphamorim raphamorim force-pushed the feat-sixel-support branch 2 times, most recently from 602bb61 to 53d8da5 Compare February 21, 2025 15:16
aymanbagabas and others added 2 commits February 21, 2025 12:17
raphamorim and others added 2 commits February 21, 2025 13:28
Co-authored-by: Ayman Bagabas <ayman.bagabas@gmail.com>
@meowgorithm meowgorithm changed the title feat: Add sixels to ansi package feat: add sixels to ansi package Feb 21, 2025
@raphamorim
Copy link
Member Author

iterm2/wezterm/rio

image

@raphamorim raphamorim changed the title feat: add sixels to ansi package feat: add sixel to ansi package Feb 21, 2025
Copy link
Member

@meowgorithm meowgorithm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't speak to the implementation details, but functionally speaking, LGTM

@raphamorim raphamorim merged commit 052644d into main Feb 21, 2025
12 checks passed
@raphamorim raphamorim deleted the feat-sixel-support branch February 21, 2025 22:50
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.

5 participants