diff options
| author | Lars Ingebrigtsen | 2016-02-09 12:44:32 +1100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2016-02-09 12:44:32 +1100 |
| commit | c93cc660ac85db9e7932ffae6bd886034defffba (patch) | |
| tree | bb433a4d98a312df336795700c7118fad86e5cca | |
| parent | 4a24af2d2b2be168e37947ceb1a3906eb1da0e55 (diff) | |
| download | emacs-c93cc660ac85db9e7932ffae6bd886034defffba.tar.gz emacs-c93cc660ac85db9e7932ffae6bd886034defffba.zip | |
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.
| -rw-r--r-- | lisp/image.el | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lisp/image.el b/lisp/image.el index 82a10a31113..b69d3b15a43 100644 --- a/lisp/image.el +++ b/lisp/image.el | |||
| @@ -913,6 +913,35 @@ has no effect." | |||
| 913 | 913 | ||
| 914 | (imagemagick-register-types) | 914 | (imagemagick-register-types) |
| 915 | 915 | ||
| 916 | (defun image-increase-size (n) | ||
| 917 | "Increase the image size by a factor of N. | ||
| 918 | If N is 3, then the image size will be increased by 30%. The | ||
| 919 | default is 20%." | ||
| 920 | (interactive "P") | ||
| 921 | (image-change-size (if n | ||
| 922 | (1+ (/ n 10)) | ||
| 923 | 1.2))) | ||
| 924 | |||
| 925 | (defun image-decrease-size (n) | ||
| 926 | "Decrease the image size by a factor of N. | ||
| 927 | If N is 3, then the image size will be decreased by 30%. The | ||
| 928 | default is 20%." | ||
| 929 | (interactive "P") | ||
| 930 | (image-change-size (if n | ||
| 931 | (- 1 (/ n 10)) | ||
| 932 | 0.8))) | ||
| 933 | |||
| 934 | (defun image-change-size (factor) | ||
| 935 | (unless (fboundp 'imagemagick-types) | ||
| 936 | (error "Can't rescale images without ImageMagick support")) | ||
| 937 | (let ((image (get-text-property (point) 'display))) | ||
| 938 | (when (or (not (consp image)) | ||
| 939 | (not (eq (car image) 'image))) | ||
| 940 | (error "No image under point")) | ||
| 941 | (plist-put (cdr image) :type 'imagemagick) | ||
| 942 | (plist-put (cdr image) :scale | ||
| 943 | (* (or (plist-get (cdr image) :scale) 1) factor)))) | ||
| 944 | |||
| 916 | (provide 'image) | 945 | (provide 'image) |
| 917 | 946 | ||
| 918 | ;;; image.el ends here | 947 | ;;; image.el ends here |