GNU bug report logs - #69565
Fit Image Width menu

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Tue, 5 Mar 2024 17:00:02 UTC

Severity: normal

Tags: patch

Fixed in version 30.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 69565 in the body.
You can then email your comments to 69565 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#69565; Package emacs. (Tue, 05 Mar 2024 17:00:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> linkov.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 05 Mar 2024 17:00:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: bug-gnu-emacs <at> gnu.org
Subject: Fit Image Width menu
Date: Tue, 05 Mar 2024 18:56:25 +0200
Tags: patch

PDF/image viewers provide a menu item "Fit Image Width".
It's very useful to read long text on images.  Therefore
here is the same for the image-mode menu:

diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index 355685e70fd..a2f1a6c2d74 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -559,6 +559,8 @@ image-mode-menu
      :help "Resize image to match the window height and width"]
     ["Fit Image to Window (Scale down only)" image-transform-fit-both
      :help "Scale image down to match the window height and width"]
+    ["Fit Image Width" image-transform-fit-to-width
+     :help "Resize image to the width of the current window."]
     ["Zoom In" image-increase-size
      :help "Enlarge the image"]
     ["Zoom Out" image-decrease-size
@@ -1574,7 +1576,6 @@ image-transform-fit-to-height
 
 (defun image-transform-fit-to-width ()
   "Fit the current image to the width of the current window."
-  (declare (obsolete image-transform-fit-to-window "29.1"))
   (interactive nil image-mode)
   (setq image-transform-resize 'fit-width)
   (image-toggle-display-image))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#69565; Package emacs. (Sat, 09 Mar 2024 03:14:02 GMT) Full text and rfc822 format available.

Message #8 received at 69565 <at> debbugs.gnu.org (full text, mbox):

From: Rudolf Adamkovič <rudolf <at> adamkovic.org>
To: Juri Linkov <juri <at> linkov.net>, 69565 <at> debbugs.gnu.org
Subject: Re: bug#69565: Fit Image Width menu
Date: Fri, 08 Mar 2024 23:28:19 +0100
Juri Linkov <juri <at> linkov.net> writes:

> +    ["Fit Image Width" image-transform-fit-to-width

To match the similar entry above, this should say "Fit Image to Window
Width", which is not only consistent but also clearer and grammatical.

> +     :help "Resize image to the width of the current window."]

Ditto, to match the similar entry above, this should say "Scale image
down to match the window width".

-- 
“Those who cannot remember the past are condemned to repeat it.”
--- George Santayana, Life of Reason: Reason in Common Sense, 1905

Rudolf Adamkovič <rudolf <at> adamkovic.org> [he/him]
Studenohorská 25, 84103 Bratislava, Slovakia, European Union




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#69565; Package emacs. (Sun, 10 Mar 2024 17:34:02 GMT) Full text and rfc822 format available.

Message #11 received at 69565 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Rudolf Adamkovič <rudolf <at> adamkovic.org>
Cc: 69565 <at> debbugs.gnu.org
Subject: Re: bug#69565: Fit Image Width menu
Date: Sun, 10 Mar 2024 19:30:03 +0200
>> +    ["Fit Image Width" image-transform-fit-to-width
>
> To match the similar entry above, this should say "Fit Image to Window
> Width", which is not only consistent but also clearer and grammatical.
>
>> +     :help "Resize image to the width of the current window."]
>
> Ditto, to match the similar entry above, this should say "Scale image
> down to match the window width".

Agreed.  This title was copied from other programs,
but should match the existing style.

OTOH, I'm worried that both 'image-transform-fit-to-width'
and 'image-transform-fit-to-height' were declared obsolete.

So I'm not going to revive them.

Instead I'll implement a more useful item
"Fill Image to Window" that will fill the image
as much as possible to the window without leaving
any glaring empty space.  This means applying
either fit-to-width to vertical images (portrait orientation),
or fit-to-height to horizontal images (landscape orientation).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#69565; Package emacs. (Fri, 15 Mar 2024 07:45:02 GMT) Full text and rfc822 format available.

Message #14 received at 69565 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Rudolf Adamkovič <rudolf <at> adamkovic.org>
Cc: 69565 <at> debbugs.gnu.org
Subject: Re: bug#69565: Fit Image Width menu
Date: Fri, 15 Mar 2024 09:28:37 +0200
[Message part 1 (text/plain, inline)]
> OTOH, I'm worried that both 'image-transform-fit-to-width'
> and 'image-transform-fit-to-height' were declared obsolete.
>
> So I'm not going to revive them.
>
> Instead I'll implement a more useful item
> "Fill Image to Window" that will fill the image
> as much as possible to the window without leaving
> any glaring empty space.  This means applying
> either fit-to-width to vertical images (portrait orientation),
> or fit-to-height to horizontal images (landscape orientation).

This works nicely:

[image-transform-fill-window.patch (text/x-diff, inline)]
diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index 3bf4dd1ad7c..3039d13d9af 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -559,6 +559,8 @@ image-mode-menu
      :help "Resize image to match the window height and width"]
     ["Fit Image to Window (Scale down only)" image-transform-fit-both
      :help "Scale image down to match the window height and width"]
+    ["Fill Window with Image" image-transform-fill-window
+     :help "Resize image to fill either width or height of the window"]
     ["Zoom In" image-increase-size
      :help "Enlarge the image"]
     ["Zoom Out" image-decrease-size
@@ -1591,6 +1593,18 @@ image-transform-fit-to-window
   (setq image-transform-resize 'fit-window)
   (image-toggle-display-image))
 
+(defun image-transform-fill-window ()
+  "Fill the window with the image while keeping image proportions.
+This means filling the window with the image as much as possible
+without leaving empty space around image edges.  Then you can use
+either horizontal or vertical scrolling to see the remaining parts
+of the image."
+  (interactive nil image-mode)
+  (let ((size (image-display-size (image-get-display-property) t)))
+    (setq image-transform-resize
+          (if (> (car size) (cdr size)) 'fit-height 'fit-width)))
+  (image-toggle-display-image))
+
 (defun image-transform-set-rotation (rotation)
   "Prompt for an angle ROTATION, and rotate the image by that amount.
 ROTATION should be in degrees."

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#69565; Package emacs. (Tue, 28 May 2024 16:54:01 GMT) Full text and rfc822 format available.

Message #17 received at 69565 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Rudolf Adamkovič <rudolf <at> adamkovic.org>
Cc: 69565 <at> debbugs.gnu.org
Subject: Re: bug#69565: Fit Image Width menu
Date: Tue, 28 May 2024 19:51:28 +0300
close 69565 30.0.50
thanks

>> OTOH, I'm worried that both 'image-transform-fit-to-width'
>> and 'image-transform-fit-to-height' were declared obsolete.
>>
>> So I'm not going to revive them.
>>
>> Instead I'll implement a more useful item
>> "Fill Image to Window" that will fill the image
>> as much as possible to the window without leaving
>> any glaring empty space.  This means applying
>> either fit-to-width to vertical images (portrait orientation),
>> or fit-to-height to horizontal images (landscape orientation).
>
> This works nicely:

One new command is better than old two commands,
so now pushed to master.




bug marked as fixed in version 30.0.50, send any further explanations to 69565 <at> debbugs.gnu.org and Juri Linkov <juri <at> linkov.net> Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Tue, 28 May 2024 16:54:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 26 Jun 2024 11:24:11 GMT) Full text and rfc822 format available.

This bug report was last modified 30 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.