Function: eca-chat-save-image-at-point

eca-chat-save-image-at-point is an interactive and natively compiled function defined in eca-chat-image.el.

Signature

(eca-chat-save-image-at-point &optional OVERLAY)

Documentation

Save the inline image at point (or last image) to a file.

Looks up the image overlay at point and falls back to the last image overlay in the buffer when none is found. When called with non-nil OVERLAY, save that overlay's image directly (used by the per-overlay keymap so a click saves the clicked image regardless of where point currently sits).

Prompts for a destination using eca-chat-save-image-directory and eca-chat-save-image-filename-format for the default path. Creates parent directories as needed. Writes the original bytes verbatim — display zoom does not affect the saved file.

Key Bindings

eca-chat-mode-map C-c C-z s

Source Code

;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-chat-image.el
(defun eca-chat-save-image-at-point (&optional overlay)
  "Save the inline image at point (or last image) to a file.
Looks up the image overlay at point and falls back to the last
image overlay in the buffer when none is found.  When called with
non-nil OVERLAY, save that overlay's image directly (used by the
per-overlay keymap so a click saves the clicked image regardless
of where point currently sits).

Prompts for a destination using `eca-chat-save-image-directory'
and `eca-chat-save-image-filename-format' for the default path.
Creates parent directories as needed.  Writes the original bytes
verbatim — display zoom does not affect the saved file."
  (interactive)
  (let ((ov (or overlay
                (eca-chat--image-overlay-at-point)
                (eca-chat--last-image-overlay))))
    (cond
     ((null ov)
      (eca-warn "No image at point or in this chat"))
     (t
      (let* ((image (overlay-get ov 'display))
             (data (and (consp image) (eq (car image) 'image)
                        (image-property image :data)))
             (media-type (overlay-get ov 'eca-chat-image-media-type)))
        (cond
         ((not data)
          (eca-warn "Image overlay has no inline data to save"))
         (t
          (let* ((dir (eca-chat--default-save-image-dir))
                 (default-name
                  (eca-chat--default-save-image-filename media-type))
                 (target (read-file-name "Save image to: "
                                         dir nil nil default-name)))
            (when (and target (not (string-empty-p target)))
              (let ((parent (file-name-directory
                             (expand-file-name target))))
                (when (and parent (not (file-directory-p parent)))
                  (make-directory parent t)))
              (let ((coding-system-for-write 'no-conversion))
                (write-region data nil target nil 'nomessage))
              (eca-info "Saved image to %s" target))))))))))