all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tino Calancha <tino.calancha@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Emacs developers <emacs-devel@gnu.org>,
	monnier@iro.umontreal.ca, Tino Calancha <tino.calancha@gmail.com>
Subject: Re: image-rotate: Accept angle as an argument
Date: Tue, 6 Sep 2016 01:30:35 +0900 (JST)	[thread overview]
Message-ID: <alpine.DEB.2.20.1609060057410.15061@calancha-pc> (raw)
In-Reply-To: <m337leseuq.fsf@gnus.org>



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
> degrees?
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 <tino.calancha@gmail.com>
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."
    (interactive)
+  (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




  parent reply	other threads:[~2016-09-05 16:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-05  5:52 image-rotate: Accept angle as an argument Tino Calancha
2016-09-05  7:52 ` Tino Calancha
2016-09-05 12:36   ` Lars Ingebrigtsen
2016-09-05 14:59     ` Stefan Monnier
2016-09-05 16:30     ` Tino Calancha [this message]
2016-09-05 16:52       ` Lars Ingebrigtsen
2016-09-05 17:28         ` Tino Calancha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1609060057410.15061@calancha-pc \
    --to=tino.calancha@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.