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

VSCode integrated terminal image preview distorted #446

Closed
baitian752 opened this issue Dec 11, 2023 · 6 comments · Fixed by #576
Closed

VSCode integrated terminal image preview distorted #446

baitian752 opened this issue Dec 11, 2023 · 6 comments · Fixed by #576
Labels
enhancement New feature or request

Comments

@baitian752
Copy link

What system are you running Yazi on?

Windows

What terminal are you running Yazi in?

VSCode integrated terminal (VSCode 1.85.0)

Yazi version

yazi 0.1.5

Did you try the latest main branch to see if the problem has already been fixed?

Tried, but the problem is still present

Describe the bug

Remote SSH for my linux server

Run yazi
image

View the first image (1024x1024, OK)
image

Back to the text file (there is an image border)
image

View the second image (1024x1536 distorted)
image

The original image:
04_04

Expected Behavior

Preview is OK.

To Reproduce

As the bug description.

Configuration

No response

Anything else?

No response

@baitian752 baitian752 added the bug Something isn't working label Dec 11, 2023
@baitian752
Copy link
Author

After some tests, I found this issue is relative to the global zoom level of VSCode, but the color is not correct at zoom level 0.

image

@sxyazi
Copy link
Owner

sxyazi commented Dec 11, 2023

Try reducing max_width and max_height to see if the issue still exists - Yazi cannot obtain the correct terminal pixel width and height for displaying images due to VSCode not implementing the ioctl(TIOCGWINSZ) system call. Therefore, fixed max_width and max_height are currently used. The issue you're describing is caused by images exceeding the available area and resulting in scrolling.

Another way to obtain pixel width and height is through CSI 14 t, but unfortunately, crossterm does not provide any way for users to extend it; it can only be added to the crossterm codebase. I've submitted a patch, but it hasn't been merged yet, crossterm-rs/crossterm#810. So, currently, in VSCode, you can only limit the image size using max_width and max_height instead of dynamically adjusting based on terminal size.

As for image colors, this is the expected behavior. Currently, VSCode only supports Sixel graphics protocol, which is a rather old protocol that only supports 256 colors. So Yazi can only use approximate colors as substitute colors for display. Until VSCode supports more advanced protocols (such as Terminal graphics protocol or Inline images protocol protocols), it cannot be improved.

@sxyazi sxyazi added the waiting on op Waiting for more information from the original poster label Dec 11, 2023
@baitian752
Copy link
Author

Thanks for you information. And for the colors, I have also test imgcat, which looks OK:

image

@github-actions github-actions bot removed the waiting on op Waiting for more information from the original poster label Dec 12, 2023
@baitian752
Copy link
Author

I have tried set preview size with max_width and max_height. It looks good, thank you.

image

@sxyazi
Copy link
Owner

sxyazi commented Dec 27, 2023

Thanks for you information. And for the colors, I have also test imgcat, which looks OK:

I think this is not a bug, it's just that Yazi's default image compression strategy is more aggressive.

I'll add a new config option to allow users to adjust the compression level manually.

Copy link

I'm going to lock this issue because it has been closed for 30 days. ⏳ This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
2 participants