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

Reported pixel size of cell incorrect. #18460

Closed
salt-die opened this issue Jan 25, 2025 · 5 comments
Closed

Reported pixel size of cell incorrect. #18460

salt-die opened this issue Jan 25, 2025 · 5 comments
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting

Comments

@salt-die
Copy link

Windows Terminal version

1.22.3232.0

Windows build number

10.0.22631.0

Other Software

No response

Steps to reproduce

I can provide the sixel ansi to produce this image if needed, but otherwise output some sixel image and count the actual number of lines used in terminal.

Expected Behavior

Expect a 100 pixel tall sixel image to cover 5 lines in the terminal if pixel geometry is (20, 10)

Actual Behavior

Related to #17504

Querying pixel size of cell returns (20, 10) as mentioned above (here, in python):

>>> print("\x1b[16t")

>>> ^[[6;20;10t

but printing an image that is 100 pixels high, say, uses 10 lines in terminal (expected 5 lines, or 20 pixels high per line):

Image

I've printed line numbers over the image to help show this.

@salt-die salt-die added Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Jan 25, 2025
@j4james
Copy link
Collaborator

j4james commented Jan 25, 2025

We'd need to see the source of test_sixel.py or the actual output that it produced to determine where the problem is, but the most likely explanation is that the pixel aspect ratio is set to 2:1, since that's what Sixel uses by default.

@salt-die
Copy link
Author

salt-die commented Jan 25, 2025

Ok, I can provide the ansi that produced the image, but I'll use a smaller image for convenience (40 pixels high):

Image

�P;0;;q";;40;80#0;2;14;17;21#1;2;22;26;31#2;2;25;29;36#3;2;18;21;25#4;2;16;20;24#5;2;21;24;30#6;2;19;22;27#7;2;21;25;30#0!42?!38~$#1!38?~!40?$#2!38~!41?$#4!41?~!37?$#5!39?I!39?$#6!40?~!38?$#7!39?t!39?-#0!42?!38~$#1!38?~!40?$#2!38~!41?$#4!41?~!37?$#5!39?d!39?$#6!40?~!38?$#7!39?Y!39?-#0!42?!38~$#1!38?~!40?$#2!38~!41?$#4!41?~!37?$#5!39?Q!39?$#6!40?~!38?$#7!39?l!39?-#0!38w!4?!38@$#1!38A@??w!38C$#2!38@!4?!38w$#3!38C!4?!38A$#4!38?w??@!37?$#5!39?Bk!38?$#6!38?C{BA!37?$#7!38?A?OC!37?-#0!38~!41?$#1!41?~!37?$#2!42?!38~$#4!38?~!40?$#5!40?S!38?$#6!39?~!39?$#7!40?j!38?-#0!38~!41?$#1!41?~!37?$#2!42?!38~$#4!38?~!40?$#5!40?I!38?$#6!39?~!39?$#7!40?t!38?-#0!38N!41?$#1!41?N!37?$#2!42?!38N$#4!38?N!40?$#5!40?D!38?$#6!39?N!39?$#7!40?I!38?-�\

Uh, hopefully that pastes ok. (I think the beginning and ending control characters didn't paste actually)
Should one just always assume pixel aspect ratio of 2:1, or is there a query for that.

@j4james
Copy link
Collaborator

j4james commented Jan 25, 2025

The aspect ratio is declared as part of the image. One way of doing this is by using the raster attributes command (the part starting with "). So in your example, the start of the sequence would need to look like this:

P;0;;q"1;1;40;80

It can also be declared in the first parameter value, although that's less obvious - the value 9 indicates an aspect ratio of 1:1. So again using your example, the start of the sequence could be changed to something like this:

P9;0;;q";;40;80

If you don't set the aspect ratio in either of those places, it defaults to 2:1. That was the only aspect ratio supported by the first Sixel terminals, so later models kept that as the default for backwards compatibility.

Regardless of how you choose to set the aspect ratio, I would also recommend you set the second parameter to 1 rather than 0 (i.e. something like P9;1q), because otherwise it'll perform a background fill before rendering the image content, and the results of that can be unpredictable, and it's almost never what you want.

Also note that the dimensions you've declared for the background are 40 wide and 80 high, which I suspect is the reverse of what you intended.

@salt-die
Copy link
Author

Thanks for the explanation! This does fix everything! The second parameter was determined by the image not having any transparent pixels. I've read somewhere that some terminals are much slower with P2=1, but maybe that's not true. Anyway, I'm satisfied and this can be closed.

@DHowett
Copy link
Member

DHowett commented Jan 25, 2025

Thanks all!

@DHowett DHowett closed this as not planned Won't fix, can't repro, duplicate, stale Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting
Projects
None yet
Development

No branches or pull requests

3 participants