with the information required by the Thumbnail Managing Standard."
:type '(choice (const :tag "Not Set" nil) file))
+;; Note: the "-text" arguments below are according to specification in
+;; https://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html#CREATION
(defcustom image-dired-cmd-pngcrush-options
`("-q"
- "-text" "b" "Description" "Thumbnail of file://%f"
- "-text" "b" "Software" ,(emacs-version)
+ "-text" "b" "Description" "Thumbnail of file://%u"
+ "-text" "b" "Software" ,(string-replace "\n" " " (emacs-version))
;; "-text b \"Thumb::Image::Height\" \"%oh\" "
;; "-text b \"Thumb::Image::Mimetype\" \"%mime\" "
;; "-text b \"Thumb::Image::Width\" \"%ow\" "
"-text" "b" "Thumb::MTime" "%m"
;; "-text b \"Thumb::Size\" \"%b\" "
- "-text" "b" "Thumb::URI" "file://%f"
+ "-text" "b" "Thumb::URI" "file://%u"
"%q" "%t")
"Arguments for `image-dired-cmd-pngcrush-program'.
The value can use the same %-format specifiers as in
-`image-dired-cmd-create-thumbnail-options', with \"%q\" for a
-temporary file name (typically generated by pnqnq)."
+`image-dired-cmd-create-thumbnail-options', with \"%q\" standing for a
+temporary file name (typically generated by pnqnq),
+and \"%u\" standing for a file URI corresponding to file in \"%f\"."
:version "26.1"
:type '(repeat (string :tag "Argument")))
:type '(repeat (string :tag "Argument"))
:link '(url-link "man:optipng(1)"))
+;; Note: the "-set" arguments below are according to specification in
+;; https://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html#CREATION
(defcustom image-dired-cmd-create-standard-thumbnail-options
(let ((opts (list
"-size" "%wx%h" "%f[0]"
"-set" "Thumb::MTime" "%m"
- "-set" "Thumb::URI" "file://%f"
- "-set" "Description" "Thumbnail of file://%f"
- "-set" "Software" (emacs-version)
+ "-set" "Thumb::URI" "file://%u"
+ "-set" "Description" "Thumbnail of file://%u"
+ "-set" "Software" (string-replace "\n" " " (emacs-version))
"-thumbnail" "%wx%h>" "png:%t")))
(if (executable-find "gm") (cons "convert" opts) opts))
"Options for creating thumbnails according to the Thumbnail Managing Standard.
Used with `image-dired-cmd-create-thumbnail-program', if that is available.
The value can use the same %-format specifiers as in
`image-dired-cmd-create-thumbnail-options', with \"%m\" for file
-modification time.
+modification time and \"%u\" for the URI of the file in \"%f\".
On MS-Windows, if the `convert' command is not available, and
`w32image-create-thumbnail' is used instead, the textual chunks
specified by the \"-set\" options will not be injected, and instead
\f
;;; Util functions
+(defun image-dired--file-URI (file)
+ ;; https://en.wikipedia.org/wiki/File_URI_scheme
+ (if (memq system-type '(windows-nt ms-dos))
+ (concat "/" file)
+ file))
+
(defun image-dired--probe-thumbnail-cmd (cmd)
"Check whether CMD is usable for thumbnail creation."
(cond
(message "command %S %s" (process-command process)
(string-replace "\n" "" status))
(message "command %S failed with status %s"
- process status))
+ process status)))
(when (or (not (processp process))
(memq (process-status process) '(exit signal)))
(let ((temp (cdr (assq ?q spec))))
- (delete-file temp))))))
+ (delete-file temp)))))
(proc
(if (eq system-type 'windows-nt)
;; See above for the reasons we don't use 'start-process'
(spec `((?s . ,size) (?w . ,size) (?h . ,size)
(?m . ,modif-time)
(?f . ,original-file)
+ (?u . ,(image-dired--file-URI original-file))
(?q . ,thumbnail-nq8-file)
(?t . ,thumbnail-file)))
(thumbnail-dir (file-name-directory thumbnail-file))
(spec `((?s . ,size) (?w . ,size) (?h . ,size)
(?m . ,modif-time)
(?f . ,original-file)
+ (?u . ,(image-dired--file-URI original-file))
(?q . ,thumbnail-nq8-file)
(?t . ,thumbnail-file))))
(cond
(let ((spec
(list
(cons ?f (expand-file-name file))
+ (cons ?u (image-dired--file-URI (expand-file-name file)))
(cons ?t tag-name)
(cons ?v tag-value))))
(apply #'call-process image-dired-cmd-write-exif-data-program nil nil nil
/* Create an image by reading from INPUT_FILE. */
wchar_t input_file_w[MAX_PATH];
- input_file = ENCODE_FILE (Fexpand_file_name (input_file, Qnil));
+ input_file
+ = ENCODE_FILE (Fexpand_file_name (Fcopy_sequence (input_file), Qnil));
unixtodos_filename (SSDATA (input_file));
filename_to_utf16 (SSDATA (input_file), input_file_w);
GpImage *file_image;
{
/* Save the thumbnail image to a file of specified TYPE. */
wchar_t thumb_file_w[MAX_PATH];
- thumb_file = ENCODE_FILE (Fexpand_file_name (thumb_file, Qnil));
+ thumb_file
+ = ENCODE_FILE (Fexpand_file_name (Fcopy_sequence (thumb_file),
+ Qnil));
unixtodos_filename (SSDATA (thumb_file));
filename_to_utf16 (SSDATA (thumb_file), thumb_file_w);
status = GdipSaveImageToFile (thumb_image, thumb_file_w,