Skip to content

Commit

Permalink
Add new rotate file commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
manateelazycat committed Dec 21, 2021
1 parent 52a715b commit d90bf59
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
37 changes: 37 additions & 0 deletions eaf-image-viewer.el
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@
("l" . "js_move_left")
("h" . "js_move_right")

("U" . "eaf-image-viewer-rotate-file-left")
("I" . "eaf-image-viewer-rotate-file-right")
("O" . "eaf-image-viewer-rotate-file-horizontal")

("d" . "delete_current_image")
("<f12>" . "open_devtools")
)
Expand All @@ -118,6 +122,39 @@
"The extension list of image viewer application."
:type 'cons)

(defun eaf-image-viewer-rotate-by-convert (file-name degrees-string)
"Rotate FILE-NAME with the passed DEGREES-STRING.
Note that the file is changed on the file-system."
;; redisplay to show the \"Rotating...\" message
(redisplay)
(shell-command
(format "convert '%s' -quality 100 -rotate %s '%s'"
file-name
degrees-string
file-name)))

(defun eaf-image-viewer-rotate-file-right ()
(interactive)
(message "Rotating...")
(eaf-call-async "eval_js_function" eaf--buffer-id "rotate_right" "")
(eaf-image-viewer-rotate-by-convert (eaf-get-path-or-url) "+90")
(message "Rotated right and saved to file system"))

(defun eaf-image-viewer-rotate-file-left ()
(interactive)
(message "Rotating...")
(eaf-call-async "eval_js_function" eaf--buffer-id "rotate_left" "")
(eaf-image-viewer-rotate-by-convert (eaf-get-path-or-url) "-90")
(message "Rotated left and saved to file system"))

(defun eaf-image-viewer-rotate-file-horizontal ()
(interactive)
(message "Rotating...")
(eaf-call-async "eval_js_function" eaf--buffer-id "rotate_horizontal" "")
(eaf-image-viewer-rotate-by-convert (eaf-get-path-or-url) "-180")
(message "Rotated horizontal and saved to file system"))

(add-to-list 'eaf-app-binding-alist '("image-viewer" . eaf-image-viewer-keybinding))

(setq eaf-image-viewer-module-path (concat (file-name-directory load-file-name) "buffer.py"))
Expand Down
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
viewer.rotate(90);
}

function rotateHorizontal() {
viewer.rotate(180);
}

function zoomOut() {
viewer.zoom(-0.1, true);
}
Expand Down

0 comments on commit d90bf59

Please sign in to comment.