              (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)

  "Compares images at file paths `expected` and `actual` and produces another
  image at path `difference` which highlights any differences in the images.

  Returns a number between `0` and `1` indicating a measure of the difference.
  with `0` indicating the images are the same."
  [expected actual difference]
  ;; use imagemagick compare executable for comparison
  ;; see https://imagemagick.org/script/compare.php
  (let [{:keys [err]} (sh/sh "compare" "-metric" "mae" expected actual difference)
        result        (second (re-find #"\((.*)\)" err))]
    (Double/parseDouble result)))

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

            (etaoin/refresh driver)
            (etaoin/screenshot-element driver {:tag :canvas} actual)
            (let [result (compare-images expected actual difference)]
              (when (number? result)
                (when (<= result threshold)
                  (io/delete-file (io/file actual))
                  (io/delete-file (io/file difference)))
                (t/is (<= result threshold)
                      (str "Image comparison for " name " not within acceptable threshold: " threshold))))))))
    (etaoin/quit driver)))
