       ;; format bit by bit.
       (with-current-buffer target-buffer
         (let ((coding-system-for-write 'binary))
-          (write-file export-file-name))))
+          ;; When exporting, we do not want to display the image in Emacs
+          ;; itself; as rendering the image in Emacs may take a significant
+          ;; amount of time, we try to inhibit the automatic image display
+          ;; by binding `image-mode' to `image-mode-as-text'
+          (let ((auto-mode-alist nil)
+                (magic-fallback-mode-alist nil))
+            (write-file export-file-name)))))
 
     (if errors-during-export
         (message "Exporting to %s ... failed (see file for details)" export-file-name)


    (message "Exporting to %s ..." export-file-name)

    (let ((target-buffer (generate-new-buffer " *temp*")))
      ;; We do not use `with-temp-buffer' here, as we want to stay in the
      ;; current buffer containing the plantuml diagram.  The reason for this is
      ;; that `planumlt-output-type' is local to the current buffer, and

(cl-defgeneric plantuml-export-string-to-buffer (exec-mode string buffer)
  "Export STRING to plantuml diagram using the given EXEC-MODE.
Use BUFFER to write the diagram to, clearing it first.  This
buffer can be written to a file or be displayed directly."
  (ignore string buffer)
  (user-error "Exporting with exec-mode %s is not supported (yet)" exec-mode))

