aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Kangas2021-10-25 02:12:48 +0200
committerStefan Kangas2021-10-25 02:12:48 +0200
commit057f45abeced1c81bd9bb2782ab6a8fe472f38c8 (patch)
tree3c2c638fd1fc0f4b103b57ad2d9b24655baa906b
parent608e694a30469392540043ce3ef627832b491f8c (diff)
downloademacs-057f45abeced1c81bd9bb2782ab6a8fe472f38c8.tar.gz
emacs-057f45abeced1c81bd9bb2782ab6a8fe472f38c8.zip
Support new Thumbnail Managing Standard sizes in image-dired
* lisp/image-dired.el (image-dired--thumbnail-managing-standard-sizes): New defconst. (image-dired-thumbnail-storage) (image-dired-thumb-name, image-dired-insert-thumbnail) (image-dired-thumb-size, image-dired-create-thumb-1): Support larger thumbnail sizes mandated by new version of the Thumbnail Managing Standard (December 2020, Version 0.9.0).
-rw-r--r--etc/NEWS7
-rw-r--r--lisp/image-dired.el52
2 files changed, 43 insertions, 16 deletions
diff --git a/etc/NEWS b/etc/NEWS
index d47a91c31f6..83899a3457c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -204,6 +204,13 @@ external "exiftool" command to be available. The user options
204The new command 'image-dired-unmark-all-marks' has been added with a 204The new command 'image-dired-unmark-all-marks' has been added with a
205binding in the menu. 205binding in the menu.
206 206
207---
208*** Support Thumbnail Managing Standard v0.9.0 (Dec 2020).
209This standard allows sharing generated thumbnails across different
210programs. Version 0.9.0 adds two larger thumbnail sizes: 512x512 and
2111024x1024 pixels. See the user option `image-dired-thumbnail-storage'
212to use it; it is not enabled by default.
213
207** Dired 214** Dired
208 215
209--- 216---
diff --git a/lisp/image-dired.el b/lisp/image-dired.el
index bca2dd117f4..9d4b7625943 100644
--- a/lisp/image-dired.el
+++ b/lisp/image-dired.el
@@ -88,8 +88,8 @@
88;; * Supports all image formats that Emacs and convert supports, but 88;; * Supports all image formats that Emacs and convert supports, but
89;; the thumbnails are hard-coded to JPEG or PNG format. It uses 89;; the thumbnails are hard-coded to JPEG or PNG format. It uses
90;; JPEG by default, but can optionally follow the Thumbnail Managing 90;; JPEG by default, but can optionally follow the Thumbnail Managing
91;; Standard, which mandates PNG. See the user option 91;; Standard (v0.9.0, Dec 2020), which mandates PNG. See the user
92;; `image-dired-thumbnail-storage'. 92;; option `image-dired-thumbnail-storage'.
93;; 93;;
94;; * WARNING: The "database" format used might be changed so keep a 94;; * WARNING: The "database" format used might be changed so keep a
95;; backup of `image-dired-db-file' when testing new versions. 95;; backup of `image-dired-db-file' when testing new versions.
@@ -180,22 +180,35 @@ values, they will be stored in the JPEG format:
180 where the image file is. 180 where the image file is.
181 181
182It can also use the \"Thumbnail Managing Standard\", which allows 182It can also use the \"Thumbnail Managing Standard\", which allows
183sharing of thumbnails across different programs. This method 183sharing of thumbnails across different programs. Thumbnails will
184means that thumbnails are saved in the PNG format, and allows for 184be stored in \"$XDG_CACHE_HOME/thumbnails/\" instead of in
185use the following file sizes: 185`image-dired-dir'. Thumbnails are saved in the PNG format, and
186can be one of the following sizes:
186 187
187- `standard' means use thumbnails sized 128x128. 188- `standard' means use thumbnails sized 128x128.
188- `standard-large' means use thumbnails sized 256x256. 189- `standard-large' means use thumbnails sized 256x256.
190- `standard-x-large' means use thumbnails sized 512x512.
191- `standard-xx-large' means use thumbnails sized 1024x1024.
189 192
190Note that with this method of storing thumbnails, they will be 193For more information on the Thumbnail Managing Standard, see:
191saved in subdirectories of `image-dired-dir'. For more
192information on the Thumbnail Managing Standard, see:
193https://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html" 194https://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html"
194 :type '(choice :tag "How to store thumbnail files" 195 :type '(choice :tag "How to store thumbnail files"
195 (const :tag "Use image-dired-dir" use-image-dired-dir) 196 (const :tag "Use image-dired-dir" use-image-dired-dir)
196 (const :tag "Thumbnail Managing Standard (normal 128x128)" standard) 197 (const :tag "Thumbnail Managing Standard (normal 128x128)"
197 (const :tag "Thumbnail Managing Standard (large 256x256)" standard-large) 198 standard)
198 (const :tag "Per-directory" per-directory))) 199 (const :tag "Thumbnail Managing Standard (large 256x256)"
200 standard-large)
201 (const :tag "Thumbnail Managing Standard (larger 512x512)"
202 standard-x-large)
203 (const :tag "Thumbnail Managing Standard (extra large 1024x1024)"
204 standard-xx-large)
205 (const :tag "Per-directory" per-directory))
206 :version "29.1")
207
208(defconst image-dired--thumbnail-standard-sizes
209 '( standard standard-large
210 standard-x-large standard-xx-large)
211 "List of symbols representing thumbnail sizes in Thumbnail Managing Standard.")
199 212
200(defcustom image-dired-db-file 213(defcustom image-dired-db-file
201 (expand-file-name ".image-dired_db" image-dired-dir) 214 (expand-file-name ".image-dired_db" image-dired-dir)
@@ -410,6 +423,8 @@ Used by `image-dired-gallery-generate' to leave out \"hidden\" images."
410 (cond 423 (cond
411 ((eq 'standard image-dired-thumbnail-storage) 128) 424 ((eq 'standard image-dired-thumbnail-storage) 128)
412 ((eq 'standard-large image-dired-thumbnail-storage) 256) 425 ((eq 'standard-large image-dired-thumbnail-storage) 256)
426 ((eq 'standard-x-large image-dired-thumbnail-storage) 512)
427 ((eq 'standard-xx-large image-dired-thumbnail-storage) 1024)
413 (t 100)) 428 (t 100))
414 "Size of thumbnails, in pixels. 429 "Size of thumbnails, in pixels.
415This is the default size for both `image-dired-thumb-width' 430This is the default size for both `image-dired-thumb-width'
@@ -583,7 +598,7 @@ Add text properties ORIGINAL-FILE-NAME and ASSOCIATED-DIRED-BUFFER."
583 (or (and (file-exists-p file) 598 (or (and (file-exists-p file)
584 (image-type-from-file-header file)) 599 (image-type-from-file-header file))
585 (and (memq image-dired-thumbnail-storage 600 (and (memq image-dired-thumbnail-storage
586 '(standard standard-large)) 601 image-dired--thumbnail-standard-sizes)
587 'png) 602 'png)
588 'jpeg) 603 'jpeg)
589 image-dired-thumb-relief 604 image-dired-thumb-relief
@@ -611,13 +626,16 @@ file name of the thumbnail will vary:
611 of the image file's directory name will be added to the 626 of the image file's directory name will be added to the
612 filename. 627 filename.
613See also `image-dired-thumbnail-storage'." 628See also `image-dired-thumbnail-storage'."
614 (cond ((memq image-dired-thumbnail-storage '(standard standard-large)) 629 (cond ((memq image-dired-thumbnail-storage
630 image-dired--thumbnail-standard-sizes)
615 (let* ((xdg (getenv "XDG_CACHE_HOME")) 631 (let* ((xdg (getenv "XDG_CACHE_HOME"))
616 (dir (if (and xdg (file-name-absolute-p xdg)) 632 (dir (if (and xdg (file-name-absolute-p xdg))
617 xdg "~/.cache")) 633 xdg "~/.cache"))
618 (thumbdir (cl-case image-dired-thumbnail-storage 634 (thumbdir (cl-case image-dired-thumbnail-storage
619 (standard "thumbnails/normal") 635 (standard "thumbnails/normal")
620 (standard-large "thumbnails/large")))) 636 (standard-large "thumbnails/large")
637 (standard-x-large "thumbnails/x-large")
638 (standard-xx-large "thumbnails/xx-large"))))
621 (expand-file-name 639 (expand-file-name
622 ;; MD5 is mandated by the Thumbnail Managing Standard. 640 ;; MD5 is mandated by the Thumbnail Managing Standard.
623 (concat (md5 (concat "file://" (expand-file-name file))) ".png") 641 (concat (md5 (concat "file://" (expand-file-name file))) ".png")
@@ -650,6 +668,8 @@ DIMENSION should be either the symbol `width' or `height'."
650 (cond 668 (cond
651 ((eq 'standard image-dired-thumbnail-storage) 128) 669 ((eq 'standard image-dired-thumbnail-storage) 128)
652 ((eq 'standard-large image-dired-thumbnail-storage) 256) 670 ((eq 'standard-large image-dired-thumbnail-storage) 256)
671 ((eq 'standard-x-large image-dired-thumbnail-storage) 512)
672 ((eq 'standard-xx-large image-dired-thumbnail-storage) 1024)
653 (t (cl-ecase dimension 673 (t (cl-ecase dimension
654 (width image-dired-thumb-width) 674 (width image-dired-thumb-width)
655 (height image-dired-thumb-height))))) 675 (height image-dired-thumb-height)))))
@@ -764,7 +784,7 @@ Increase at own risk.")
764 (mapcar 784 (mapcar
765 (lambda (arg) (format-spec arg spec)) 785 (lambda (arg) (format-spec arg spec))
766 (if (memq image-dired-thumbnail-storage 786 (if (memq image-dired-thumbnail-storage
767 '(standard standard-large)) 787 image-dired--thumbnail-standard-sizes)
768 image-dired-cmd-create-standard-thumbnail-options 788 image-dired-cmd-create-standard-thumbnail-options
769 image-dired-cmd-create-thumbnail-options)))) 789 image-dired-cmd-create-thumbnail-options))))
770 790
@@ -783,7 +803,7 @@ Increase at own risk.")
783 ;; PNG thumbnail has been created since we are 803 ;; PNG thumbnail has been created since we are
784 ;; following the XDG thumbnail spec, so try to optimize 804 ;; following the XDG thumbnail spec, so try to optimize
785 (when (memq image-dired-thumbnail-storage 805 (when (memq image-dired-thumbnail-storage
786 '(standard standard-large)) 806 image-dired--thumbnail-standard-sizes)
787 (cond 807 (cond
788 ((and image-dired-cmd-pngnq-program 808 ((and image-dired-cmd-pngnq-program
789 (executable-find image-dired-cmd-pngnq-program)) 809 (executable-find image-dired-cmd-pngnq-program))