emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master c93cc66 2/3: Add new commands to allow changing the


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master c93cc66 2/3: Add new commands to allow changing the size of images
Date: Tue, 09 Feb 2016 02:36:37 +0000

branch: master
commit c93cc660ac85db9e7932ffae6bd886034defffba
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Add new commands to allow changing the size of images
    
    * lisp/image.el (image-increase-size, image-decrease-size):
    New commands.
    (image-change-size): New function.
---
 lisp/image.el |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/lisp/image.el b/lisp/image.el
index 82a10a3..b69d3b1 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -913,6 +913,35 @@ has no effect."
 
 (imagemagick-register-types)
 
+(defun image-increase-size (n)
+  "Increase the image size by a factor of N.
+If N is 3, then the image size will be increased by 30%.  The
+default is 20%."
+  (interactive "P")
+  (image-change-size (if n
+                         (1+ (/ n 10))
+                       1.2)))
+
+(defun image-decrease-size (n)
+  "Decrease the image size by a factor of N.
+If N is 3, then the image size will be decreased by 30%.  The
+default is 20%."
+  (interactive "P")
+  (image-change-size (if n
+                         (- 1 (/ n 10))
+                       0.8)))
+
+(defun image-change-size (factor)
+  (unless (fboundp 'imagemagick-types)
+    (error "Can't rescale images without ImageMagick support"))
+  (let ((image (get-text-property (point) 'display)))
+    (when (or (not (consp image))
+              (not (eq (car image) 'image)))
+      (error "No image under point"))
+    (plist-put (cdr image) :type 'imagemagick)
+    (plist-put (cdr image) :scale
+               (* (or (plist-get (cdr image) :scale) 1) factor))))
+
 (provide 'image)
 
 ;;; image.el ends here



reply via email to

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