Last active
May 12, 2023 05:23
-
-
Save radixm46/b19084a10081540a02f283f757ac447e to your computer and use it in GitHub Desktop.
Convert multiple jpg files in clipboard to png
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env emacs --script | |
(if (eq system-type 'darwin) | |
(dolist (fpath (split-string (shell-command-to-string "pbpaste") "\n" t)) | |
(let* ((output (replace-regexp-in-string "\\(?:\\.\\w+\\)?$" ".jpg" fpath)) | |
(cmd (format "sips -s format jpeg -s formatOptions 80 \'%s\' --out \'%s\'" | |
fpath output))) | |
(when (and (file-exists-p fpath) | |
(string-match-p "\\.png\\'" fpath)) | |
(princ (format "=> cocnvert: %s\n" fpath)) | |
(shell-command cmd)))) | |
(progn (princ "system not seems Darwin, exit...") | |
(kill-emacs 1))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment