emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Auto-resizing of images in image-mode


From: Eli Zaretskii
Subject: Re: Auto-resizing of images in image-mode
Date: Sun, 19 Apr 2020 17:06:05 +0300

> From: Juri Linkov <address@hidden>
> Cc: address@hidden
> Date: Sun, 19 Apr 2020 02:45:18 +0300
> 
> Please see in commit 4df8a61117 if everything is correct
> according to your comments.

LGTM, thanks.

> > Maybe so, but Emacs 26 still shows the images in their original size,
> > AFAICT.  So this is new in Emacs 27, at least for me.  I think that's
> > because previously the automatic resizing worked only in Emacs built
> > with ImageMagick, whereas in Emacs 27 we can resize natively.  I build
> > my Emacs without ImageMagick, and I wonder how many others do, due to
> > ImageMagick's instability.
> 
> I'm not sure how it could be new in Emacs 27 because
> image-transform-resize was added in year 2014.

It's new for me, because I build Emacs without ImageMagick.

> Better would be to have two ways to view an image without the
> automatic resizing:
> 
> 1. an option to disable automatic resizing permanently.
>    There is already a defvar 'image-transform-resize'
>    but its 'nil' value doesn't disable automatic resizing,
>    so a new defcustom is needed.  Please see it below.
> 
> 2. an easy to type key in image-mode-map to toggle automatic resizing.
>    Some programs use 'F' key for "Best Fit" but 'F' is already used
>    in image-mode-map for image-goto-frame.

That's fine with me, thanks.

> Also there are no keys for image-transform-fit-to-width,
> image-transform-fit-to-height and image-transform-reset.
> I thought about using a prefix key 'f', so using 'f w' to fit width,
> but 'f' is already taken too.
> 
> But anyway their docstrings say:
> 
>   This command has no effect unless Emacs is compiled with
>   ImageMagick support.
> 
> So these commands should be fixed to work without ImageMagick.

Right.  But that's for master, I think.

> Then three new defcustoms like these could be added:
> 
> (defcustom image-resize t
>   "Non-nil to resize the image upon first display.
> Its value should be one of the following:
>  - nil, meaning no resizing.
>  - t, meaning to fit the image to the window height and width.
>  - `fit-height', meaning to fit the image to the window height.
>  - `fit-width', meaning to fit the image to the window width.
>  - A number, which is a scale factor (the default size is 1)."
>   :type '(choice (const :tag "No resizing" nil)
>                  (other :tag "Fit height and width" t)
>                (const :tag "Fit height" fit-height)
>                (const :tag "Fit width" fit-width)
>                (number :tag "Scale factor" 1))
>   :version "27.1"
>   :group 'image)
> 
> (defcustom image-window-resize t
>   "Non-nil to resize the image whenever the window's dimensions change."
>   :type 'boolean
>   :version "27.1"
>   :group 'image)
> 
> (defcustom image-window-resize-delay 1
>   "Number of seconds to wait before resizing according to 
> `image-window-resize'."
>   :type 'integer
>   :version "27.1"
>   :group 'image)
> 
> If this looks good, I could send a complete patch.

Please do, and thanks.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]