feat: display images using sixel or kitty #138
Merged
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.
#117
The display of images has been initially implemented, but due to issues with BubbleTea or its UI library (I guess), the image rendering appears strange.
When I print the image directly to the terminal using
fmt.Print, it looks fine.However, when integrated with BubbleTea, the image suffers from unusual cropping.
The workaround I have found so far is to reduce
m.preview.Heightand scaling the image to a specific resolution. But the image resolution is unrelated to the size of the terminal window.Below is a table I tested, representing the maximum resolution at which the image can be correctly displayed on the terminal. The resolution of the image is (
windowWidth*scale.x,windowHeight*scale.y).The display quality is poor when dealing with very tall images. Sometimes, the image only shows in the upper half of the terminal. However, it performs well with regular square images, which might be sufficient for preview purposes.
Users need to manually modify the configuration file to set ImageDisplay to either kitty or sixel. ImageScaleX and ImageScaleY represent scale.x and scale.y in the table, HeightCut represents m.preview.Height. These values need to be adjusted according to the actual situation. Personally, I recommend setting HeightCut to 2, as there's no noticeable difference compared to other values.