[Top][All Lists]

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

Re: image-rotate: Accept angle as an argument

From: Tino Calancha
Subject: Re: image-rotate: Accept angle as an argument
Date: Tue, 6 Sep 2016 01:30:35 +0900 (JST)
User-agent: Alpine 2.20 (DEB 67 2015-01-07)

On Mon, 5 Sep 2016, Lars Ingebrigtsen wrote:

Anyway, I don't really see the use case here: The only reason somebody
(in real life) has for changing the displayed angle of an image is if
it's vertical instead of horizontal (and vice versa), so rotating by 90
degrees is the only thing that makes sense, I think.

Do you see a use case for changing the displayed angle of an image by 72
I think not, but unfortunately i am not the right person to answer: i don't like photograpy.
You are right, these commands are fine.
OTOH, I read at the first line of the file that image.el is the image API: Why don't we provide a function 'image--change-orientation' and use it
in the 'image-rotate' implementation? (See patch below)
The new function playing similar role as 'image--change-size' in 'image-increase-size'.
Then, users will keep using the same commands, but programs might
use 'image--change-orientation' if they need it.
This came to my mind after looking image-mode.el:
i guess the code in image-mode.el for the rotations/resizes would be
much simple using the API from image.el.

commit e4621bb833ba0bf6b1d62800c1d03137458bc58e
Author: Tino Calancha <address@hidden>
Date:   Tue Sep 6 01:24:05 2016 +0900

    Extract function from image-rotate accepting arbitrary angles

    * lisp/image.el (image--change-orientation): New defun.
    (image-rotate): Use it.

diff --git a/lisp/image.el b/lisp/image.el
index e1f52de..780305e 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -1011,9 +1011,12 @@ image--current-scaling
 (defun image-rotate ()
   "Rotate the image under point by 90 degrees clockwise."
+  (image--change-orientation 90))
+(defun image--change-orientation (angle)
   (let ((image (image--get-imagemagick-and-warn)))
     (plist-put (cdr image) :rotation
-               (float (mod (+ (or (plist-get (cdr image) :rotation) 0) 90)
+               (float (mod (+ (or (plist-get (cdr image) :rotation) 0) angle)
                            ;; We don't want to exceed 360 degrees
                            ;; rotation, because it's not seen as valid
                            ;; in exif data.

Repository revision: 62e4dc4660cb3b29cfffcad0639e51c7f382ced8

reply via email to

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