-
Notifications
You must be signed in to change notification settings - Fork 65
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
Do not upscale picture #84
Comments
Chafa doesn't actually take the whole terminal by default. You can see this with a tiny image (something like If we try to map it to something closer to the actual pixel size, it would likely take up only 1 or 2 cells, which would make it unrecognizable. One could argue that we could use a smaller size when there is a pixel-perfect alternative (sixels/kitty/iterm), but I think it's nice to produce a consistent screen size across all protocols... |
I understand the point when the rendering is not pixel-perfect.
My request was initially done with pixel-perfect renderers in mind
(I should have clarified that).
A good test is to render, in Kitty, chafa-logo.gif with both timg and
chafa. Chafa result is twice the size of timg result with some decreased
visibility (as you are now zoomed in on a pixelated animation).
I don’t have a perfect solution here. What I realize, as a end user is
that I prefer original size when pixel perfect rendering is used and
clearer possible output otherwise. (well, this last point is quite
debatable in my own case because if I know that the rendering is small,
it usually means that it’s an icon and I should not really care about
it).
Thinking out loud here: I would be interested to try a kind of
"never-upscale" option that would use size only as a higher limit. I
would be really curious to see what it does in Offpunk as, currently,
important pictures are rendered the same size as small icons (which are,
hopefully, most of the time removed by python-readability).
|
This is somewhat complicated by the fact that the Chafa API expresses dimensions in terms of cells, so some scaling (and aspect distortion) will happen no matter what. At smaller sizes, the relative distortion is greater. That is, the lost fraction is a greater portion of the total (e.g. rounding 2x2.5 to 2x3 results in greater distortion than rounding 40x40.5 to 40x41). So: Making images tiny can also make them kind of ugly. Regarding a maximum size, there is currently such a thing, although it's not directly controllable. It's taken from the detected terminal size (falling back to 80x25 if detection fails). It could make sense to allow direct control of that. Here's what I think we could do:
I think this would do what you want and give some extra flexibility too. And it preserves existing behavior. What do you think? Edit: Actually, |
This looks like a good idea but what would happen if I give --scale=1
and the resulting picture is bigger than the max size ?
If I understand correctly, --size overide --scale. Thus adding a --size
makes the --scale useless, right?
Also, how would it works with pixel-perfect rendering such as
Kitty-protocol?
(I realize it’s a hard problem, so it might be interesting to see if
there are other usecases like mine or if I’m wrong about what I think I
want).
|
Correct, It would work the same with pixel-perfect (or near-perfect) rendering; it'd cover the same number of cells as the symbol output does (keeps it predictable). |
I’m a bit confused with all those options. How would I say "makes it natural size except if it’s bigger than the terminal, in which case resize to the terminal size" ? |
|
Then it’s perfect for my needs :-) |
The 1.12.0 release now has the |
By default, displaying a picture with Chafa takes the whole terminal.
It would be nice to not upscale smaller pictures so the user can get a sense of the size of the picture (for example if it is an icon).
The "does not upscale" option could work together with the size option to set the size as "maximal size". If I set the size to 100 but I’m viewing an icon which is 10x10, the icon stays at 10x10.
The text was updated successfully, but these errors were encountered: