hzeller / timg

A terminal image and video viewer.
GNU General Public License v2.0
1.91k stars 73 forks source link

Grid parameter ignored for pdfs #94

Closed xeruf closed 7 months ago

xeruf commented 1 year ago
image

When previewing a pdf, the --grid parameter value is completely ignored.

hzeller commented 1 year ago

Interesting, indeed. The reason is, that a PDF is treated as single 'image' as it is a single file even though it has multiple sub-images.

This should probably be broken up and behave as if it was separate independent images that then nicely arrange in the grid.

hzeller commented 1 year ago

Alright, should be fixed now. Can you do a fresh git pull, recompile and test with your PDF ?

xeruf commented 1 year ago

Thank you, works :)

Just a little thing, but that might also be the fault of kitty - When I allow height overflow, there is a slight offset within the grid:

image
timg --grid=2 Oceans\ \(D\)\ -\ Akkorde.pdf -W

Scrolled up:

image
hzeller commented 1 year ago

I don't observe that with Kitty, but maybe the PDF has different page sizes ? I have to test for that situation and double check that -W works in these cases.

(BTW, if you add --auto-crop unnecessary whitespace around is cropped, so you might get less of the whitespace pixels using up space).

Re-opening now while investigation is going on to reproduce.

xeruf commented 1 year ago

I am seeing this for any PDF with multiple pages, all A4, even with auto-crop enabled (which is a good hint, thank you :) )

As said, this is only when the height overflows i.e. each image is bigger than the terminal height. It also happens for images, so this is not PDF-related.

hzeller commented 7 months ago

So the problem here is, that if you have -W, a page might be longer than the terminal and have to scroll down a little. but in the grid, the cursor needs to jump up to the next page. Now, the way terminals work, they don't allow to jump the cursor beyond the top of the terminal. So if the previos page is a bit longer, the next page will only be displayed starting from the position it could jump to .. slightly down.

So there is nothing we can do about this here.

In the latest release ( https://github.com/hzeller/timg/releases/tag/v1.6.0 ), the resolution of the rendering has been improved. I typically can easily read PDS with --grid=2x1 -U or even --grid=3x1 (also, it is faster). So if you read PDFs a lot, this might be an interesting release for you.