displayed image. This keymap defines the following commands:
@table @kbd
-@item +
+@item i +
Increase the image size (@code{image-increase-size}). A prefix value
of @samp{4} means to increase the size by 40%. The default is 20%.
-@item -
+@item i -
Decrease the image size (@code{image-increase-size}). A prefix value
of @samp{4} means to decrease the size by 40%. The default is 20%.
-@item r
+@item i r
Rotate the image by 90 degrees clockwise (@code{image-rotate}).
A prefix means to rotate by 90 degrees counter-clockwise instead.
-@item o
+@item i h
+Flip the image horizontally (@code{image-flip-horizontally}).
+
+@item i v
+Flip the image vertically (@code{image-flip-vertically}).
+
+@item i o
Save the image to a file (@code{image-save}).
-@item c
+@item i c
Crop the image interactively (@code{image-crop}).
-@item x
+@item i x
Cut a rectangle from the image interactively (@code{image-cut}).
@end table
+The size and rotation commands are ``repeating'', which means that you
+can continue adjusting the image without using the @kbd{i} prefix.
+
@node Multi-Frame Images
@subsection Multi-Frame Images
@cindex multi-frame images
\f
* Incompatible changes in Emacs 29.1
++++
+*** The image commands have changed key bindings.
+In previous Emacs versions, images have had the '+', '-' and 'r' keys
+bound when point is over an image. In Emacs 29.1, additional commands
+were added, and this made it more likely that users would trigger the
+image commands by mistake. To avoid this, all image commands have
+moved to the 'i' keymap, so '+' is now 'i +', '-' is now 'i -', and
+'r' is now 'i r'. In addition, these commands are now repeating, so
+you can rotate an image twice by saying 'i r r', for instance.
+
+++
*** Emacs now picks the correct coding system for X input methods.
Previously, Emacs would use the locale coding system for input
+++
*** New commands: 'image-flip-horizontally' and 'image-flip-vertically'.
-These commands horizontally and vertically flip the image under point.
+These commands horizontally and vertically flip the image under point,
+and are bound to 'i h' and 'i v', respectively.
+++
*** New command 'image-transform-set-percent'.
+++
** New commands 'image-crop' and 'image-cut.
These commands allow interactively cropping/cutting the image at
-point. The commands are bound to keys 'c' and 'x' (respectively) in
-the local keymap over images. They rely on external programs, by
+point. The commands are bound to keys 'i c' and 'i x' (respectively)
+in the local keymap over images. They rely on external programs, by
default "convert" from ImageMagick, to do the actual cropping/eliding
of the image file.
(defvar-keymap image-map
:doc "Map put into text properties on images."
- "-" #'image-decrease-size
- "+" #'image-increase-size
- "r" #'image-rotate
- "o" #'image-save
- "c" #'image-crop
- "x" #'image-cut
- "h" #'image-flip-horizontally
- "v" #'image-flip-vertically
+ "i" (define-keymap
+ "-" #'image-decrease-size
+ "+" #'image-increase-size
+ "r" #'image-rotate
+ "o" #'image-save
+ "c" #'image-crop
+ "x" #'image-cut
+ "h" #'image-flip-horizontally
+ "v" #'image-flip-vertically)
"C-<wheel-down>" #'image-mouse-decrease-size
"C-<mouse-5>" #'image-mouse-decrease-size
"C-<wheel-up>" #'image-mouse-increase-size
(imagemagick-register-types)
+(defvar-keymap image--repeat-map
+ "+" #'image-increase-size
+ "-" #'image-decrease-size
+ "r" #'image-rotate)
+
(defun image-increase-size (&optional n position)
"Increase the image size by a factor of N.
If N is 3, then the image size will be increased by 30%. The
default is 20%."
(interactive "P")
+ (image--delayed-change-size (if n
+ (1+ (/ (prefix-numeric-value n) 10.0))
+ 1.2)
+ position)
+ (set-transient-map image--repeat-map nil nil
+ "Use %k for further adjustments"))
+
+(defun image--delayed-change-size (size position)
;; Wait for a bit of idle-time before actually performing the change,
;; so as to batch together sequences of closely consecutive size changes.
;; `image--change-size' just changes one value in a plist. The actual
;; image resizing happens later during redisplay. So if those
;; consecutive calls happen without any redisplay between them,
;; the costly operation of image resizing should happen only once.
- (run-with-idle-timer 0.3 nil
- #'image--change-size
- (if n
- (1+ (/ (prefix-numeric-value n) 10.0))
- 1.2)
- position))
+ (run-with-idle-timer 0.3 nil #'image--change-size size position))
(defun image-decrease-size (&optional n position)
"Decrease the image size by a factor of N.
If N is 3, then the image size will be decreased by 30%. The
default is 20%."
(interactive "P")
- ;; Wait for a bit of idle-time before actually performing the change,
- ;; so as to batch together sequences of closely consecutive size changes.
- ;; `image--change-size' just changes one value in a plist. The actual
- ;; image resizing happens later during redisplay. So if those
- ;; consecutive calls happen without any redisplay between them,
- ;; the costly operation of image resizing should happen only once.
- (run-with-idle-timer 0.3 nil
- #'image--change-size
- (if n
- (- 1 (/ (prefix-numeric-value n) 10.0))
- 0.8)
- position))
+ (image--delayed-change-size (if n
+ (- 1 (/ (prefix-numeric-value n) 10.0))
+ 0.8)
+ position)
+ (set-transient-map image--repeat-map nil nil
+ "Use %k for further adjustments"))
(defun image-mouse-increase-size (&optional event)
"Increase the image size using the mouse."
(or angle 90))
;; We don't want to exceed 360 degrees rotation,
;; because it's not seen as valid in Exif data.
- 360)))))
+ 360))))
+ (set-transient-map image--repeat-map nil nil
+ "Use %k for further adjustments"))
(defun image-save ()
"Save the image under point.