* lisp/image-mode.el (image-transform-set-percent): New command.
(image-mode-map): Bind above new command to "s p".
* doc/emacs/files.texi (Image Mode): Document it.
@findex image-transform-set-scale
@findex image-transform-reset
To resize the image manually you can use the command
-@code{image-transform-fit-to-window} bound to @kbd{s w}
-that fits the image to both the window height and width.
-To scale the image specifying a scale factor, use the command
-@code{image-transform-set-scale} bound to @kbd{s s}.
-To reset all transformations to the initial state, use
-@code{image-transform-reset} bound to @kbd{s 0}.
+@code{image-transform-fit-to-window} bound to @kbd{s w} that fits the
+image to both the window height and width. To scale the image to a
+percentage of its original size, use the command
+@code{image-transform-set-percent} bound to @kbd{s p}. To scale
+the image specifying a scale factor, use the command
+@code{image-transform-set-scale} bound to @kbd{s s}. To reset all
+transformations to the initial state, use @code{image-transform-reset}
+bound to @kbd{s 0}.
@findex image-next-file
@findex image-previous-file
*** New commands: 'image-flip-horizontally' and 'image-flip-vertically'.
These commands horizontally and vertically flip the image under point.
++++
+*** New command 'image-transform-set-percent'.
+It allows setting the image size to a percentage of its original size,
+and is bound to "s p" in Image mode.
+
** Images
+++
"s h" #'image-transform-fit-to-height
"s i" #'image-transform-fit-to-width
"s b" #'image-transform-fit-both
+ "s p" #'image-transform-set-percent
"s s" #'image-transform-set-scale
"s r" #'image-transform-set-rotation
"s m" #'image-transform-set-smoothing
(list :transform-smoothing
(string= image--transform-smoothing "smooth")))))))
+(defun image-transform-set-percent (scale)
+ "Prompt for a percentage, and resize the current image to that size.
+The percentage is in relation to the original size of the image."
+ (interactive (list (read-number "Scale (% of original): " 100
+ 'read-number-history)))
+ (unless (cl-plusp scale)
+ (error "Not a positive number: %s" scale))
+ (setq image-transform-resize (/ scale 100.0))
+ (image-toggle-display-image))
+
(defun image-transform-set-scale (scale)
"Prompt for a number, and resize the current image by that amount."
(interactive "nScale: ")