commit 7de2d816d7dc5db442b744f98c321396ab39c054
parent 1d5f8baf63a127d3c0b98b4465f73141e096d583
Author: Tomas Hlavaty <tom@logand.com>
Date: Sat, 29 Aug 2020 13:55:52 +0200
add ability to turn images
Diffstat:
1 file changed, 31 insertions(+), 0 deletions(-)
diff --git a/emacs-framebuffer.el b/emacs-framebuffer.el
@@ -17,6 +17,7 @@
;;; - sha256sum from coreutils
;;; - pdftocairo and pdfinfo from poppler-utils to display pdf
;;; - abiword to display abw, doc, docx, odt, rtf
+;;; - imagemagick to modify images
;;;
;;; Example configuration:
;;;
@@ -481,6 +482,9 @@
(insert "- space: scroll down\n")
(insert "- u: scroll up\n")
(insert "- w: fit width\n")
+ (insert "- R: turn right (modifies the image)\n")
+ (insert "- L: turn left (modifies the image)\n")
+ (insert "- U: turn upside-down (modifies the image)\n")
)
(setq buffer-read-only t)
(goto-char (point-min))
@@ -540,6 +544,30 @@
(interactive)
(framebuffer-image-mode-change-scale :fit-height))
+(defun framebuffer-image-mode-turn-right ()
+ (interactive)
+ (let ((f (buffer-file-name)))
+ (call-process "convert" nil nil nil "-rotate" "90" f f))
+ (setq framebuffer-image-mode-image-size
+ (cons (cdr framebuffer-image-mode-image-size)
+ (car framebuffer-image-mode-image-size)))
+ (framebuffer-image-mode-draw-image (current-buffer)))
+
+(defun framebuffer-image-mode-turn-left ()
+ (interactive)
+ (let ((f (buffer-file-name)))
+ (call-process "convert" nil nil nil "-rotate" "-90" f f))
+ (setq framebuffer-image-mode-image-size
+ (cons (cdr framebuffer-image-mode-image-size)
+ (car framebuffer-image-mode-image-size)))
+ (framebuffer-image-mode-draw-image (current-buffer)))
+
+(defun framebuffer-image-mode-turn-upside-down ()
+ (interactive)
+ (let ((f (buffer-file-name)))
+ (call-process "convert" nil nil nil "-rotate" "180" f f))
+ (framebuffer-image-mode-draw-image (current-buffer)))
+
(add-hook
'framebuffer-image-mode-hook
(lambda ()
@@ -556,6 +584,9 @@
(define-key framebuffer-image-mode-map "spc" 'framebuffer-image-mode-scroll-down)
(define-key framebuffer-image-mode-map "u" 'framebuffer-image-mode-scroll-up)
(define-key framebuffer-image-mode-map "w" 'framebuffer-image-mode-fit-width)
+ (define-key framebuffer-image-mode-map "R" 'framebuffer-image-mode-turn-right)
+ (define-key framebuffer-image-mode-map "L" 'framebuffer-image-mode-turn-left)
+ (define-key framebuffer-image-mode-map "U" 'framebuffer-image-mode-turn-upside-down)
))
(defun framebuffer-install ()