aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/image
diff options
context:
space:
mode:
authorStefan Kangas2022-09-28 00:41:01 +0200
committerStefan Kangas2022-09-28 12:36:42 +0200
commit6cffaa3b6daf767808a9d9ae549fc2aea5c5c07e (patch)
tree6e7eb37733a87b8eabb2ba1b3657b329825ce4ba /lisp/image
parentb5b59d1b8afe1e13f63190b9688ddfd9605f2945 (diff)
downloademacs-6cffaa3b6daf767808a9d9ae549fc2aea5c5c07e.tar.gz
emacs-6cffaa3b6daf767808a9d9ae549fc2aea5c5c07e.zip
image-dired: End thumbnail file names with ".jpg"
* lisp/image/image-dired-util.el (image-dired-thumb-name): Always end thumbnail name in ".jpg" and simplify naming to just use the SHA-1 hash. (Bug#57961) * test/lisp/image/image-dired-util-tests.el (image-dired-thumb-name/image-dired): Adjust test for the above change. * etc/NEWS: Announce the above change.
Diffstat (limited to 'lisp/image')
-rw-r--r--lisp/image/image-dired-util.el53
1 files changed, 22 insertions, 31 deletions
diff --git a/lisp/image/image-dired-util.el b/lisp/image/image-dired-util.el
index e7d116d90ba..dd746886a43 100644
--- a/lisp/image/image-dired-util.el
+++ b/lisp/image/image-dired-util.el
@@ -70,37 +70,28 @@ file name of the thumbnail will vary:
70 of the image file's directory name will be added to the 70 of the image file's directory name will be added to the
71 filename. 71 filename.
72See also `image-dired-thumbnail-storage'." 72See also `image-dired-thumbnail-storage'."
73 (cond ((memq image-dired-thumbnail-storage 73 (let ((file (expand-file-name file)))
74 image-dired--thumbnail-standard-sizes) 74 (cond ((memq image-dired-thumbnail-storage
75 (let ((thumbdir (cl-case image-dired-thumbnail-storage 75 image-dired--thumbnail-standard-sizes)
76 (standard "thumbnails/normal") 76 (let ((thumbdir (cl-case image-dired-thumbnail-storage
77 (standard-large "thumbnails/large") 77 (standard "thumbnails/normal")
78 (standard-x-large "thumbnails/x-large") 78 (standard-large "thumbnails/large")
79 (standard-xx-large "thumbnails/xx-large")))) 79 (standard-x-large "thumbnails/x-large")
80 (expand-file-name 80 (standard-xx-large "thumbnails/xx-large"))))
81 ;; MD5 is mandated by the Thumbnail Managing Standard. 81 (expand-file-name
82 (concat (md5 (concat "file://" (expand-file-name file))) ".png") 82 ;; MD5 is mandated by the Thumbnail Managing Standard.
83 (expand-file-name thumbdir (xdg-cache-home))))) 83 (concat (md5 (concat "file://" file)) ".png")
84 ((or (eq 'image-dired image-dired-thumbnail-storage) 84 (expand-file-name thumbdir (xdg-cache-home)))))
85 ;; Maintained for backwards compatibility: 85 ((or (eq 'image-dired image-dired-thumbnail-storage)
86 (eq 'use-image-dired-dir image-dired-thumbnail-storage)) 86 ;; Maintained for backwards compatibility:
87 (let* ((f (expand-file-name file)) 87 (eq 'use-image-dired-dir image-dired-thumbnail-storage))
88 (hash (md5 (file-name-as-directory (file-name-directory f))))) 88 (expand-file-name (format "%s.jpg" (sha1 file))
89 (expand-file-name 89 (image-dired-dir)))
90 (format "%s%s.thumb.%s" 90 ((eq 'per-directory image-dired-thumbnail-storage)
91 (file-name-base f) 91 (expand-file-name (format "%s.thumb.jpg" file)
92 (if hash (concat "_" hash) "") 92 (expand-file-name
93 (file-name-extension f)) 93 ".image-dired"
94 (image-dired-dir)))) 94 (file-name-directory file)))))))
95 ((eq 'per-directory image-dired-thumbnail-storage)
96 (let ((f (expand-file-name file)))
97 (expand-file-name
98 (format "%s.thumb.%s"
99 (file-name-base f)
100 (file-name-extension f))
101 (expand-file-name
102 ".image-dired"
103 (file-name-directory f)))))))
104 95
105(defvar image-dired-thumbnail-buffer "*image-dired*" 96(defvar image-dired-thumbnail-buffer "*image-dired*"
106 "Image-Dired's thumbnail buffer.") 97 "Image-Dired's thumbnail buffer.")