From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.devel Subject: Re: image-rotate: Accept angle as an argument Date: Tue, 6 Sep 2016 01:30:35 +0900 (JST) Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Trace: blaine.gmane.org 1473093067 16038 195.159.176.226 (5 Sep 2016 16:31:07 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 5 Sep 2016 16:31:07 +0000 (UTC) User-Agent: Alpine 2.20 (DEB 67 2015-01-07) Cc: Emacs developers , monnier@iro.umontreal.ca, Tino Calancha To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 05 18:31:03 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bgwnS-00034t-02 for ged-emacs-devel@m.gmane.org; Mon, 05 Sep 2016 18:30:58 +0200 Original-Received: from localhost ([::1]:55787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgwnP-00083U-QN for ged-emacs-devel@m.gmane.org; Mon, 05 Sep 2016 12:30:55 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgwnG-00083B-QT for emacs-devel@gnu.org; Mon, 05 Sep 2016 12:30:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bgwnA-000364-Qx for emacs-devel@gnu.org; Mon, 05 Sep 2016 12:30:45 -0400 Original-Received: from mail-pa0-x241.google.com ([2607:f8b0:400e:c03::241]:34256) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgwnA-00035x-Je for emacs-devel@gnu.org; Mon, 05 Sep 2016 12:30:40 -0400 Original-Received: by mail-pa0-x241.google.com with SMTP id hm5so5077102pac.1 for ; Mon, 05 Sep 2016 09:30:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=58CSWr6UcOtU0qSFdJ3+YyR7Dma8FG/Fz/9tq8eNcFc=; b=C77FtnyD91Phuy0J7dsxMxoPb+pz655AyfVCJzQdzamlR53vtJFvj9tCEZUI54sMQs 4v0my1ORuEDX4FhKYfxqgu/tCKbyTe8GGw7H7IfYpLFwm6dYW4ZhIYRjnRz8Y8ky7I2J kxaSyldxGI9F+Uk3bggF5oei5NGWGXfNuwOjIAE1oDDZtkRG8oL9/k/B56UtIuxAxk0/ +77VkuXSSDUH//HUkvnY9ZoqEP6ZrgcX+X9WjA0JRT+f3MX/rzrxkFyCJP+UUH/tPdVN bnqpSBP9tZoDQbhU6mdUCcPtU6v40J1mpD1ZoElhbGaLHlbiGRswNxai27ioVnBx4mLm +xkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=58CSWr6UcOtU0qSFdJ3+YyR7Dma8FG/Fz/9tq8eNcFc=; b=ORAFX2f1N6p2c6lO0yJSXwt+2GLaMAW7SXOJP6TkRPa5mynlIgIpTtMIy4KJKyoy7D dPRscttFWnh55vWIrg7sC5E2oxLq4GTdGqQAhmE/2ec01OXrOxvJfHJW2Lm+NbcemYdv u4aabZHDt+rW1n7y0fi6AX7dl9NcQCwg7x4Kq9k8EF7rLoiEwDCWBNJqfPXAF8ZJFO5U NJzDsiX3MGWfEQfL22vmNb7O5bkttEzMWOgsQEq4O5xnKPUBkfpTBkhcT9xO8O0bCQRd 3Uk+4UUpj9bFyUpG38XbKgx0t/Aj1z2qzJIIrFDEJgmuKWfvkXsQLYW+dDV2se0dwiTI NleA== X-Gm-Message-State: AE9vXwPgnHt4JLLbbmgqCzTE53nFCvgjgMI45qlo/f91ulDmV8MhXC/rXkvp/0AJNDxiLQ== X-Received: by 10.66.183.206 with SMTP id eo14mr27750795pac.146.1473093039750; Mon, 05 Sep 2016 09:30:39 -0700 (PDT) Original-Received: from calancha-pc (69.191.218.133.dy.bbexcite.jp. [133.218.191.69]) by smtp.gmail.com with ESMTPSA id q4sm34690814pfb.18.2016.09.05.09.30.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Sep 2016 09:30:39 -0700 (PDT) X-Google-Original-From: Tino Calancha X-X-Sender: calancha@calancha-pc In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c03::241 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:207198 Archived-At: 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 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