summaryrefslogtreecommitdiff
path: root/lisp/image.el
diff options
context:
space:
mode:
authorBasil L. Contovounesios <contovob@tcd.ie>2019-07-16 22:51:27 +0100
committerBasil L. Contovounesios <contovob@tcd.ie>2019-07-20 16:00:31 +0100
commitb728620a756db78b8cb0a41afa72db6209102cdf (patch)
tree30b5a0597791fe9a47cae18dda203d737b453bfa /lisp/image.el
parent6b882ea3532fffe31e2f27bfec265129a5e80348 (diff)
downloademacs-b728620a756db78b8cb0a41afa72db6209102cdf.tar.gz
Allow counter-clockwise rotations in image-rotate
* lisp/image.el (image-rotate): Extend with an optional argument specifying the rotation in degrees (bug#35421). * doc/lispref/display.texi (Showing Images): * etc/NEWS: Document the change. * test/lisp/image-tests.el (image-rotate): New test.
Diffstat (limited to 'lisp/image.el')
-rw-r--r--lisp/image.el22
1 files changed, 13 insertions, 9 deletions
diff --git a/lisp/image.el b/lisp/image.el
index b58b1dc9542..c3e28655c38 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -1028,16 +1028,20 @@ default is 20%."
(display-width (car (image-size image t))))
(/ (float display-width) image-width)))
-(defun image-rotate ()
- "Rotate the image under point by 90 degrees clockwise."
- (interactive)
+(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."
+ (interactive (and current-prefix-arg '(-90)))
(let ((image (image--get-imagemagick-and-warn)))
- (plist-put (cdr image) :rotation
- (float (mod (+ (or (plist-get (cdr image) :rotation) 0) 90)
- ;; We don't want to exceed 360 degrees
- ;; rotation, because it's not seen as valid
- ;; in exif data.
- 360)))))
+ (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)))))
(defun image-save ()
"Save the image under point."