about summary refs log tree commit diff
diff options
context:
space:
mode:
authorArun Isaac2020-08-02 03:43:14 +0530
committerArun Isaac2020-08-03 01:24:12 +0530
commit117d9519a14e3224390167c7b078061ff2b5f567 (patch)
tree77ab1041d1ed8838e2d9bbb015127cec0d111a78
parent8532a822124904e70618818dfaf12f09752e8e9f (diff)
downloadennum-117d9519a14e3224390167c7b078061ff2b5f567.tar.gz
ennum-117d9519a14e3224390167c7b078061ff2b5f567.tar.lz
ennum-117d9519a14e3224390167c7b078061ff2b5f567.zip
Expose paths to external utilities.
* ennum-image.el (ennum-image-convert-path, ennum-image-identify-path,
ennum-image-jpegtran-path, ennum-image-optipng-path): New variables.
(ennum-image-resize-image): Use ennum-image-convert-path.
(ennum-image-optimize-image): Use ennum-image-jpegtran-path and
ennum-image-optipng-path.
(ennum-image-get-width): Use ennum-image-identify-path.
-rw-r--r--ennum-image.el35
1 files changed, 30 insertions, 5 deletions
diff --git a/ennum-image.el b/ennum-image.el
index 3a8aa23..21ab205 100644
--- a/ennum-image.el
+++ b/ennum-image.el
@@ -3,6 +3,26 @@
 (require 'image)
 (require 'seq)
 
+(defcustom ennum-image-convert-path
+  "convert"
+  "Path to imagemagick convert executable."
+  :type 'string)
+
+(defcustom ennum-image-identify-path
+  "identify"
+  "Path to imagemagick identify executable."
+  :type 'string)
+
+(defcustom ennum-image-jpegtran-path
+  "jpegtran"
+  "Path to jpegtran executable."
+  :type 'string)
+
+(defcustom ennum-image-optipng-path
+  "optipng"
+  "Path to optipng executable."
+  :type 'string)
+
 ;; Check if all necessary image types are supported
 (seq-do (lambda (image-type)
           (unless (image-type-available-p image-type)
@@ -13,7 +33,10 @@
 (seq-do (lambda (external-program)
           (unless (executable-find external-program)
             (lwarn '(ennum) :error "`%s' not found" external-program)))
-        '("convert" "identify" "jpegtran" "optipng"))
+        (list ennum-image-convert-path
+              ennum-image-identify-path
+              ennum-image-jpegtran-path
+              ennum-image-optipng-path))
 
 (defun ennum-image-resize-image (infile-path outfile-path width)
   "A simple shell wrapper around ImageMagick's convert"
@@ -22,7 +45,7 @@
     (svg
      (copy-file infile-path outfile-path t))
     (otherwise
-     (call-process "convert" nil nil nil
+     (call-process ennum-image-convert-path nil nil nil
                    infile-path "-resize" (format "%d>" width) outfile-path)))
   outfile-path)
 
@@ -31,11 +54,13 @@
   (ennum-image--assert-file-exists image-path)
   (cl-case (image-type image-path)
     (jpeg
-     (call-process "jpegtran" nil nil nil "-optimize"
+     (call-process ennum-image-jpegtran-path
+                   nil nil nil "-optimize"
                    "-progressive" "-copy" "none"
                    "-outfile" image-path image-path))
     (png
-     (call-process "optipng" nil nil nil image-path)))
+     (call-process ennum-image-optipng-path
+                   nil nil nil image-path)))
   image-path)
 
 (defun ennum-image-get-width (image-path)
@@ -44,7 +69,7 @@
     (svg 1e+INF)
     (otherwise
      (with-temp-buffer
-       (call-process "identify" nil t nil
+       (call-process ennum-image-identify-path nil t nil
                      "-format" "%w" image-path)
        (string-to-number (buffer-string))))))