lem icon indicating copy to clipboard operation
lem copied to clipboard

Request to scale image in image-viewer-mode to fit the buffer size

Open Dima-369 opened this issue 2 years ago • 10 comments

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.

image

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:

image

Dima-369 avatar Jul 21 '23 18:07 Dima-369

2 cents because I didn't know the keys before:

  • image-zoom-[out/in] bound to C - - and C - +
  • image-zoom-reset C - 0

vindarel avatar Jul 21 '23 21:07 vindarel

We added the keys +, - and 0 on the main branch.

vindarel avatar Jul 22 '23 11:07 vindarel

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.

Dima-369 avatar Jul 23 '23 09:07 Dima-369

ah damn! Thanks for testing. I'll need to test more with your input and send another PR.

vindarel avatar Jul 23 '23 11:07 vindarel

(ping @Dima-369 ) Did this PR https://github.com/lem-project/lem/pull/875 solved the issue?

Sasanidas avatar Dec 07 '23 14:12 Sasanidas

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

Dima-369 avatar Dec 07 '23 15:12 Dima-369

(ping @vindarel to maybe help)

Sasanidas avatar Dec 08 '23 20:12 Sasanidas

  • 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)

vindarel avatar Dec 11 '23 18:12 vindarel

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 avatar Dec 13 '23 11:12 Dima-369

@Dima-369 It was a feature, there was a check that the image was smaller :p Should be good now.

vindarel avatar Dec 20 '23 15:12 vindarel