Function: mml--possibly-alter-image

mml--possibly-alter-image is a byte-compiled function defined in mml.el.gz.

Signature

(mml--possibly-alter-image FILE-NAME IMAGE)

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/mml.el.gz
;; FIXME presumably (built-in) ImageMagick could replace exiftool?
(defun mml--possibly-alter-image (file-name image)
  (if (or (null image)
	  (not (consp image))
	  (not (eq (car image) 'image))
	  (not (image-property image :rotation))
	  (not (executable-find "exiftool")))
      `((filename . ,file-name))
    `((filename . ,file-name)
      (buffer
       .
       ,(with-current-buffer (mml-generate-new-buffer " *mml rotation*")
	  (set-buffer-multibyte nil)
	  (call-process "exiftool"
			file-name
			(list (current-buffer) nil)
			nil
			(format "-Orientation#=%d"
				(cl-case (truncate
					  (image-property image :rotation))
				  (0 0)
				  (90 6)
				  (180 3)
				  (270 8)
				  (otherwise 0)))
			"-o" "-"
			"-")
	  (current-buffer))))))