emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 79f7e87: image-dired: Add support for GraphicsMagick


From: Stefan Kangas
Subject: master 79f7e87: image-dired: Add support for GraphicsMagick
Date: Sun, 24 Oct 2021 21:50:15 -0400 (EDT)

branch: master
commit 79f7e87da5037f22be07954bb8000ee88e18e515
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefan@marxist.se>

    image-dired: Add support for GraphicsMagick
    
    * lisp/image-dired.el (image-dired-cmd-create-thumbnail-program)
    (image-dired-cmd-create-thumbnail-options)
    (image-dired-cmd-create-temp-image-program)
    (image-dired-cmd-create-temp-image-options)
    (image-dired-cmd-rotate-thumbnail-program)
    (image-dired-cmd-rotate-thumbnail-options): Add support for the
    GraphicsMagick command line tool ("gm convert", "gm mogrify").
---
 etc/NEWS            |  5 +++++
 lisp/image-dired.el | 53 +++++++++++++++++++++++++++++++++++------------------
 2 files changed, 40 insertions(+), 18 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 83899a3..73f9b2a 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -211,6 +211,11 @@ programs.  Version 0.9.0 adds two larger thumbnail sizes: 
512x512 and
 1024x1024 pixels.  See the user option `image-dired-thumbnail-storage'
 to use it; it is not enabled by default.
 
+---
+*** Support GraphicsMagick command line tools.
+Support for the GraphicsMagick command line tool ("gm") has been
+added, and is used instead of ImageMagick when it is available.
+
 ** Dired
 
 ---
diff --git a/lisp/image-dired.el b/lisp/image-dired.el
index 9d4b762..e2aba71 100644
--- a/lisp/image-dired.el
+++ b/lisp/image-dired.el
@@ -59,16 +59,22 @@
 ;; PREREQUISITES
 ;; =============
 ;;
-;; * The ImageMagick package.  Currently, `convert' and `mogrify' are
-;; used.  Find it here: https://www.imagemagick.org.
+;; * The GraphicsMagick or ImageMagick package; Image-Dired uses
+;;   whichever is available.
+;;
+;;   A) For GraphicsMagick, `gm' is used.
+;;      Find it here:  http://www.graphicsmagick.org/
+;;
+;;   B) For ImageMagick, `convert' and `mogrify' are used.
+;;      Find it here:  https://www.imagemagick.org.
 ;;
 ;; * For non-lossy rotation of JPEG images, the JpegTRAN program is
-;; needed.
+;;   needed.
 ;;
 ;; * For `image-dired-set-exif-data' to work, the command line tool `exiftool' 
is
-;; needed.  It can be found here: https://exiftool.org/.  This
-;; function is, among other things, used for writing comments to
-;; image files using `image-dired-thumbnail-set-image-description'.
+;;   needed.  It can be found here: https://exiftool.org/.  This
+;;   function is, among other things, used for writing comments to
+;;   image files using `image-dired-thumbnail-set-image-description'.
 ;;
 ;;
 ;; USAGE
@@ -242,36 +248,45 @@ expects to find pictures in this directory."
   :type 'string)
 
 (defcustom image-dired-cmd-create-thumbnail-program
-  "convert"
+  (if (executable-find "gm") "gm" "convert")
   "Executable used to create thumbnail.
 Used together with `image-dired-cmd-create-thumbnail-options'."
-  :type 'file)
+  :type 'file
+  :version "29.1")
 
 (defcustom image-dired-cmd-create-thumbnail-options
-  '("-size" "%wx%h" "%f[0]" "-resize" "%wx%h>" "-strip" "jpeg:%t")
+  (let ((opts '("-size" "%wx%h" "%f[0]"
+                "-resize" "%wx%h>"
+                "-strip" "jpeg:%t")))
+    (if (executable-find "gm") (cons "convert" opts) opts))
   "Options of command used to create thumbnail image.
 Used with `image-dired-cmd-create-thumbnail-program'.
 Available format specifiers are: %w which is replaced by
 `image-dired-thumb-width', %h which is replaced by `image-dired-thumb-height',
 %f which is replaced by the file name of the original image and %t
 which is replaced by the file name of the thumbnail file."
-  :version "26.1"
+  :version "29.1"
   :type '(repeat (string :tag "Argument")))
 
-(defcustom image-dired-cmd-create-temp-image-program "convert"
+(defcustom image-dired-cmd-create-temp-image-program
+  (if (executable-find "gm") "gm" "convert")
   "Executable used to create temporary image.
 Used together with `image-dired-cmd-create-temp-image-options'."
-  :type 'file)
+  :type 'file
+  :version "29.1")
 
 (defcustom image-dired-cmd-create-temp-image-options
-  '("-size" "%wx%h" "%f[0]" "-resize" "%wx%h>" "-strip" "jpeg:%t")
+  (let ((opts '("-size" "%wx%h" "%f[0]"
+                "-resize" "%wx%h>"
+                "-strip" "jpeg:%t")))
+    (if (executable-find "gm") (cons "convert" opts) opts))
   "Options of command used to create temporary image for display window.
 Used together with `image-dired-cmd-create-temp-image-program',
 Available format specifiers are: %w and %h which are replaced by
 the calculated max size for width and height in the image display window,
 %f which is replaced by the file name of the original image and %t which
 is replaced by the file name of the temporary file."
-  :version "26.1"
+  :version "29.1"
   :type '(repeat (string :tag "Argument")))
 
 (defcustom image-dired-cmd-pngnq-program
@@ -352,20 +367,22 @@ Available format specifiers are the same as in
   :type '(repeat (string :tag "Argument")))
 
 (defcustom image-dired-cmd-rotate-thumbnail-program
-  "mogrify"
+  (if (executable-find "gm") "gm" "mogrify")
   "Executable used to rotate thumbnail.
 Used together with `image-dired-cmd-rotate-thumbnail-options'."
-  :type 'file)
+  :type 'file
+  :version "29.1")
 
 (defcustom image-dired-cmd-rotate-thumbnail-options
-  '("-rotate" "%d" "%t")
+  (let ((opts '("-rotate" "%d" "%t")))
+    (if (executable-find "gm") (cons "mogrify" opts) opts))
   "Arguments of command used to rotate thumbnail image.
 Used with `image-dired-cmd-rotate-thumbnail-program'.
 Available format specifiers are: %d which is replaced by the
 number of (positive) degrees to rotate the image, normally 90 or 270
 \(for 90 degrees right and left), %t which is replaced by the file name
 of the thumbnail file."
-  :version "26.1"
+  :version "29.1"
   :type '(repeat (string :tag "Argument")))
 
 (defcustom image-dired-cmd-rotate-original-program



reply via email to

[Prev in Thread] Current Thread [Next in Thread]