Function: image-dired-thumb-name

image-dired-thumb-name is a byte-compiled function defined in image-dired.el.gz.

Signature

(image-dired-thumb-name FILE)

Documentation

Return thumbnail file name for FILE.

Depending on the value of image-dired-thumbnail-storage, the file name will vary. For central thumbnail file storage, make a MD5-hash of the image file's directory name and add that to make the thumbnail file name unique. For per-directory storage, just add a subdirectory. For standard storage, produce the file name according to the Thumbnail Managing Standard.

Source Code

;; Defined in /usr/src/emacs/lisp/image-dired.el.gz
(defun image-dired-thumb-name (file)
  "Return thumbnail file name for FILE.
Depending on the value of `image-dired-thumbnail-storage', the file
name will vary.  For central thumbnail file storage, make a
MD5-hash of the image file's directory name and add that to make
the thumbnail file name unique.  For per-directory storage, just
add a subdirectory.  For standard storage, produce the file name
according to the Thumbnail Managing Standard."
  (cond ((memq image-dired-thumbnail-storage '(standard standard-large))
         (let* ((xdg (getenv "XDG_CACHE_HOME"))
                (dir (if (and xdg (file-name-absolute-p xdg))
                         xdg "~/.cache"))
                (thumbdir (cl-case image-dired-thumbnail-storage
                            (standard "thumbnails/normal")
                            (standard-large "thumbnails/large"))))
           (expand-file-name
            (concat (md5 (concat "file://" (expand-file-name file))) ".png")
            (expand-file-name thumbdir dir))))
        ((eq 'use-image-dired-dir image-dired-thumbnail-storage)
         (let* ((f (expand-file-name file))
                (md5-hash
                 ;; Is MD5 hashes fast enough? The checksum of a
                 ;; thumbnail file name need not be that
                 ;; "cryptographically" good so a faster one could
                 ;; be used here.
                 (md5 (file-name-as-directory (file-name-directory f)))))
           (format "%s%s%s.thumb.%s"
                   (file-name-as-directory (expand-file-name (image-dired-dir)))
                   (file-name-base f)
                   (if md5-hash (concat "_" md5-hash) "")
                   (file-name-extension f))))
        ((eq 'per-directory image-dired-thumbnail-storage)
         (let ((f (expand-file-name file)))
           (format "%s.image-dired/%s.thumb.%s"
                   (file-name-directory f)
                   (file-name-base f)
                   (file-name-extension f))))))