unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#69565: Fit Image Width menu
@ 2024-03-05 16:56 Juri Linkov
  2024-03-08 22:28 ` Rudolf Adamkovič
  0 siblings, 1 reply; 5+ messages in thread
From: Juri Linkov @ 2024-03-05 16:56 UTC (permalink / raw)
  To: 69565

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





^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#69565: Fit Image Width menu
  2024-03-05 16:56 bug#69565: Fit Image Width menu Juri Linkov
@ 2024-03-08 22:28 ` Rudolf Adamkovič
  2024-03-10 17:30   ` Juri Linkov
  0 siblings, 1 reply; 5+ messages in thread
From: Rudolf Adamkovič @ 2024-03-08 22:28 UTC (permalink / raw)
  To: Juri Linkov, 69565

Juri Linkov <juri@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@adamkovic.org> [he/him]
Studenohorská 25, 84103 Bratislava, Slovakia, European Union





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#69565: Fit Image Width menu
  2024-03-08 22:28 ` Rudolf Adamkovič
@ 2024-03-10 17:30   ` Juri Linkov
  2024-03-15  7:28     ` Juri Linkov
  0 siblings, 1 reply; 5+ messages in thread
From: Juri Linkov @ 2024-03-10 17:30 UTC (permalink / raw)
  To: Rudolf Adamkovič; +Cc: 69565

>> +    ["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).





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#69565: Fit Image Width menu
  2024-03-10 17:30   ` Juri Linkov
@ 2024-03-15  7:28     ` Juri Linkov
  2024-05-28 16:51       ` Juri Linkov
  0 siblings, 1 reply; 5+ messages in thread
From: Juri Linkov @ 2024-03-15  7:28 UTC (permalink / raw)
  To: Rudolf Adamkovič; +Cc: 69565

[-- Attachment #1: Type: text/plain, Size: 507 bytes --]

> 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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: image-transform-fill-window.patch --]
[-- Type: text/x-diff, Size: 1466 bytes --]

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."

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#69565: Fit Image Width menu
  2024-03-15  7:28     ` Juri Linkov
@ 2024-05-28 16:51       ` Juri Linkov
  0 siblings, 0 replies; 5+ messages in thread
From: Juri Linkov @ 2024-05-28 16:51 UTC (permalink / raw)
  To: Rudolf Adamkovič; +Cc: 69565

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.





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-05-28 16:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-05 16:56 bug#69565: Fit Image Width menu Juri Linkov
2024-03-08 22:28 ` Rudolf Adamkovič
2024-03-10 17:30   ` Juri Linkov
2024-03-15  7:28     ` Juri Linkov
2024-05-28 16:51       ` Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).