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

Nothing is rendered at all for very small images at full size #46

Open
AlanDeSmet opened this issue Mar 22, 2019 · 2 comments
Open

Nothing is rendered at all for very small images at full size #46

AlanDeSmet opened this issue Mar 22, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@AlanDeSmet
Copy link
Contributor

Given the attached files, I'd expect some sort of output, but tiv reports nothing.

./tiv -f 1x1.png 2x2.png 3x3.png 4x4.png 5x5.png 

5x5
4x4
3x3
2x2
1x1

I believe this applies to any image less than 8 pixel tall or 4 pixels wide. Ideally, something should be rendered for these tiny images.

I'm imaging two options:

My initial thought was to rescale the image so it's at least 4x8. This commit does exactly that. It's the only commit on the branch fix-tiny.

However, I'm now thinking of a different approach: If the image is smaller than target window in both directions, scale up to fill the space, but limit the scale to the the largest integer that won't cause the image to exceed the allotted space. Also use nearest neightbor interpolation. The result should provide larger "pixels". On the down side, this approach won't work for images that are very narrow but tall or very wide but short. That may yet require special case logic.

@AlanDeSmet
Copy link
Contributor Author

AlanDeSmet commented Mar 22, 2019

I'm happy to take a crack at the second proposal I made above, but before I dive in, I'd like to know if you'd welcome it. :-)

@stefanhaustein
Copy link
Owner

stefanhaustein commented Mar 22, 2019

I think the general algorithm should be as follows:

  1. Scale down as necessary to meet the w/h constraints (I think this should work already, but I think that somebody pointed out that determining the terminal size might not work when redirecting the output?)
  2. Expand (=pad) to the nearest 4x8 size

The main problem with 2 might be that we might not know the best background color... perhaps just use the bottom right corner pixel color? Or just black or white?

@stefanhaustein stefanhaustein added the bug Something isn't working label Mar 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants