Request to scale image in image-viewer-mode to fit the buffer size
For instance, if you open a very large image, it is cut and not fully displayed:
In Emacs (by default, I think) the image is resized to fit the buffer's width and height for a good preview size.
I used this 3000x3000px image: https://fastly.picsum.photos/id/653/3000/3000.jpg?hmac=8ikcT_sejQ03UptLre2ZC6uV_QJIKk-6s_7-muUcem4
Here is how it looks like in Emacs for me:
2 cents because I didn't know the keys before:
-
image-zoom-[out/in]bound toC - -andC - + -
image-zoom-resetC - 0
We added the keys +, - and 0 on the main branch.
I tested this and (fit-to-screen) does not work properly for the 3000x3000px image and my screen resolution. It triggers the (t nil) case in (cond). If I change (fit-to-screen buffer) to (fit-to-height buffer) in (open-image-buffer), it properly works for me.
So even with the current commit, I see the same state as in the issue description.
ah damn! Thanks for testing. I'll need to test more with your input and send another PR.
(ping @Dima-369 ) Did this PR https://github.com/lem-project/lem/pull/875 solved the issue?
Hmm, M-x image-fit-to-screen does not really work at all. See the video:
https://github.com/lem-project/lem/assets/15002298/f40f1be1-6446-4d50-ab52-57313de15803
(ping @vindarel to maybe help)
- does it work with your original 3000x3000 image?
- in this use case, is it the following:
- small image, fit to screen does nothing (I wouldn't be surprised, might not be a bug but a feature : p )
- fit to width and fit to height work
- fit to screen again does nothing
- rezise window, fit to screen does nothing
- ?
(can't test right now, annoying breaking changes in my Lem)
does it work with your original 3000x3000 image?
Yeah, then it works just fine, but not for the smaller one.
in this use case, is it the following:
Yup, that's it. fit to screen does nothing when the image is already larger than the viewport.
@Dima-369 It was a feature, there was a check that the image was smaller :p Should be good now.