Function: image-rotate

image-rotate is an interactive and byte-compiled function defined in image.el.gz.

Signature

(image-rotate &optional ANGLE)

Documentation

Rotate the image under point by ANGLE degrees clockwise.

If nil, ANGLE defaults to 90. Interactively, rotate the image 90 degrees clockwise with no prefix argument, and counter-clockwise with a prefix argument. Note that most image types support rotations by only multiples of 90 degrees.

When user option image-recompute-map-p is non-nil, the image's :map is recomputed to fit the newly transformed image.

View in manual

Probably introduced at or before Emacs version 27.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/image.el.gz
(defun image-rotate (&optional angle)
  "Rotate the image under point by ANGLE degrees clockwise.
If nil, ANGLE defaults to 90.  Interactively, rotate the image 90
degrees clockwise with no prefix argument, and counter-clockwise
with a prefix argument.  Note that most image types support
rotations by only multiples of 90 degrees.

When user option `image-recompute-map-p' is non-nil, the image's `:map'
is recomputed to fit the newly transformed image."
  (interactive (and current-prefix-arg '(-90)))
  (let ((image (image--get-imagemagick-and-warn)))
    (setf (image-property image :rotation)
          (float (mod (+ (or (image-property image :rotation) 0)
                         (or angle 90))
                      ;; We don't want to exceed 360 degrees rotation,
                      ;; because it's not seen as valid in Exif data.
                      360)))
    (when (and (image-property image :original-map) image-recompute-map-p)
      (setf (image-property image :map) (image--compute-map image))))
  (set-transient-map image--repeat-map nil nil
                     "Use %k for further adjustments"))