Function: image-dired-thumb-name

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

Signature

(image-dired-thumb-name FILE)

Documentation

Return absolute file name for thumbnail FILE.

Depending on the value of image-dired-thumbnail-storage and image-dired-thumb-naming, the file name of the thumbnail will vary:

- If image-dired-thumbnail-storage is set to one of the value
  of image-dired--thumbnail-standard-sizes, produce the file
  name according to the Thumbnail Managing Standard. Among other
  things, an MD5-hash of the image file's directory name will be
  added to the file name.

- Otherwise image-dired-thumbnail-storage is used to set the
  directory where to store the thumbnail. In this latter case,
  if image-dired-thumbnail-storage is set to image-dired the
  file name given to the thumbnail depends on the value of
  image-dired-thumb-naming.

See also image-dired-thumbnail-storage and image-dired-thumb-naming.

Source Code

;; Defined in /usr/src/emacs/lisp/image/image-dired-util.el.gz
(defun image-dired-thumb-name (file)
  "Return absolute file name for thumbnail FILE.
Depending on the value of `image-dired-thumbnail-storage' and
`image-dired-thumb-naming', the file name of the thumbnail will
vary:

- If `image-dired-thumbnail-storage' is set to one of the value
  of `image-dired--thumbnail-standard-sizes', produce the file
  name according to the Thumbnail Managing Standard.  Among other
  things, an MD5-hash of the image file's directory name will be
  added to the file name.

- Otherwise `image-dired-thumbnail-storage' is used to set the
  directory where to store the thumbnail.  In this latter case,
  if `image-dired-thumbnail-storage' is set to `image-dired' the
  file name given to the thumbnail depends on the value of
  `image-dired-thumb-naming'.

See also `image-dired-thumbnail-storage' and
`image-dired-thumb-naming'."
  (let ((file (expand-file-name file)))
    (if (memq image-dired-thumbnail-storage
              image-dired--thumbnail-standard-sizes)
        (let ((thumbdir (cl-case image-dired-thumbnail-storage
                          (standard "thumbnails/normal")
                          (standard-large "thumbnails/large")
                          (standard-x-large "thumbnails/x-large")
                          (standard-xx-large "thumbnails/xx-large"))))
          (expand-file-name
           ;; MD5 and PNG is mandated by the Thumbnail Managing
           ;; Standard.
           (concat (md5 (concat "file://" file)) ".png")
           (expand-file-name thumbdir (xdg-cache-home))))
      (let ((name (if (eq 'sha1-contents image-dired-thumb-naming)
                      (image-dired-contents-sha1 file)
                    ;; Defaults to SHA-1 of file name
                    (sha1 file))))
        (cond ((or (eq 'image-dired image-dired-thumbnail-storage)
                   ;; Maintained for backwards compatibility:
                   (eq 'use-image-dired-dir image-dired-thumbnail-storage))
               (expand-file-name (format "%s.jpg" name) (image-dired-dir)))
              ((eq 'per-directory image-dired-thumbnail-storage)
               (expand-file-name (format "%s.thumb.jpg"
                                         (file-name-nondirectory file))
                                 (expand-file-name
                                  ".image-dired"
                                  (file-name-directory file)))))))))