               processing-type info)))
         (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link))
           (let ((source (org-export-file-uri (match-string 1 formula-link))))
-            (when (and (memq processing-type '(dvipng convert))
-                       (not IS-WINDOWS) ; relies on posix path
-                       (executable-find "identify"))
-              (apply #'plist-put attributes (+org-msg-img-scale-css source)))
             (org-html--wrap-latex-environment
-             (org-html--format-image source attributes info)
+             (org-html--format-image source
+                                     (append attributes
+                                             (when (memq processing-type '(dvipng convert))
+                                                          (+org-msg-img-scale-css source)))
+                                     info)
              info caption label)))))
      (t (org-html--wrap-latex-environment latex-frag info caption label)))))

(defun +org-msg-img-scale-css (img-uri)
  "For a given IMG-URI, use imagemagik to find its width."
  (if +org-msg-currently-exporting
      ;; TODO change to use 'file' (NB: would only work for PNG though, apparently)
      (let ((width-call (doom-call-process "identify" "-format" "%w"
                                           (substring img-uri 7)))) ; 7=(length "file://")
        (when (= (car width-call) 0)
          (list :width
                (format "%.1fpx"
                        (/ (string-to-number (cdr width-call))
                           (plist-get org-format-latex-options :scale))))))
    (list :style (format "transform: scale(%.3f)"
                         (/ 1.0 (plist-get org-format-latex-options :scale))))))


             (org-html-format-latex latex-frag processing-type info)))
        (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link))
          (let ((source (org-export-file-uri (match-string 1 formula-link)))
                (attributes (append (list :alt latex-frag
                                          :class
                                          (concat "latex-fragment-"
                                                  (if (equal "\\(" (substring latex-frag 0 2))
                                                      "inline" "block")))
                                    (when (memq processing-type '(dvipng convert))
                                    (+org-msg-img-scale-css source)))))
            (org-html--format-image source attributes info)))))
     (t latex-frag))))

