                "save"
                "time-and-date"} snippet-name))
 
+(defn- imagemagick-installed? []
+  (try
+    (sh/sh "compare" "-version")
+    true
+    (catch java.io.IOException e false)))
+
 (defn- compare-images
   "Compares images at file paths `expected` and `actual` and produces another
   image at path `difference` which highlights any differences in the images.

  ;; see https://imagemagick.org/script/compare.php
  (let [{:keys [err]} (sh/sh "compare" "-metric" "mae" expected actual difference)
        result        (second (re-find #"\((.*)\)" err))]
    (edn/read-string result)))

(defn- replace-suffix [file-name suffix]
  (string/replace file-name #"(\w+)\.(\w+)$" (str suffix ".$2")))

             (try
               (q/background 255)
               (body)
               (if (imagemagick-installed?)
                 (assert-unchanged-snippet-output name)
                 (println "Imagemagick not detected. Please install it for automated image comparison to work."))
               (catch Exception e
                 (println "Error" e)
                 (.printStackTrace e)
