Function: image-dired-create-thumb-2
image-dired-create-thumb-2 is a byte-compiled function defined in
image-dired-external.el.gz.
Signature
(image-dired-create-thumb-2 ORIGINAL-FILE THUMBNAIL-FILE)
Documentation
For ORIGINAL-FILE, create thumbnail image named THUMBNAIL-FILE.
This is like image-dired-create-thumb-1, but used when the thumbnail
file is created by Emacs itself.
Source Code
;; Defined in /usr/src/emacs/lisp/image/image-dired-external.el.gz
(defun image-dired-create-thumb-2 (original-file thumbnail-file)
"For ORIGINAL-FILE, create thumbnail image named THUMBNAIL-FILE.
This is like `image-dired-create-thumb-1', but used when the thumbnail
file is created by Emacs itself."
(let ((size (image-dired--thumb-size))
(thumbnail-dir (file-name-directory thumbnail-file)))
(when (not (file-exists-p thumbnail-dir))
(with-file-modes #o700
(make-directory thumbnail-dir t))
(message "Thumbnail directory created: %s" thumbnail-dir))
(image-dired-debug "Creating thumbnail for %s" original-file)
(if (null (w32image-create-thumbnail original-file thumbnail-file
(file-name-extension thumbnail-file)
size size))
(message "Failed to create a thumbnail for %s"
(abbreviate-file-name original-file))
(clear-image-cache thumbnail-file)
;; PNG thumbnail has been created since we are following the XDG
;; thumbnail spec, so try to optimize.
(when (memq image-dired-thumbnail-storage
image-dired--thumbnail-standard-sizes)
(let* ((modif-time (format-time-string
"%s" (file-attribute-modification-time
(file-attributes original-file))))
(thumbnail-nq8-file (replace-regexp-in-string
".png\\'" "-nq8.png" 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
((and image-dired-cmd-pngnq-program
(executable-find image-dired-cmd-pngnq-program))
(image-dired-pngnq-thumb spec))
((and image-dired-cmd-pngcrush-program
(executable-find image-dired-cmd-pngcrush-program))
(image-dired-pngcrush-thumb spec))
((and image-dired-cmd-optipng-program
(executable-find image-dired-cmd-optipng-program))
(image-dired-optipng-thumb spec))))))
;; Trigger next in queue once a thumbnail has been created.
(image-dired-thumb-queue-run)))