diff --git a/lisp/image-dired.el b/lisp/image-dired.el
index 85bc924..7a6dfa2 100644
--- a/lisp/image-dired.el
+++ b/lisp/image-dired.el
@@ -229,7 +229,9 @@ Used together with `image-dired-cmd-create-thumbnail-options'."
   :group 'image-dired)
 
 (defcustom image-dired-cmd-create-thumbnail-options
-  '("-size" "%wx%h" "%f[0]" "-resize" "%wx%h>" "-strip" "jpeg:%t")
+  ;; '("-size" "%wx%h" "%f[0]" "-resize" "%wx%h>" "-flatten" "-strip" "jpeg:%t")
+  ;;; The `-flatten` argument makes a transparent PNG background white.
+  "%p -size %wx%h \"%f[0]\" -resize \"%wx%h>\" -flatten -strip jpeg:\"%t\""
   "Options of command used to create thumbnail image.
 Used with `image-dired-cmd-create-thumbnail-program'.
 Available format specifiers are: %w which is replaced by
@@ -247,7 +249,8 @@ Used together with `image-dired-cmd-create-temp-image-options'."
   :group 'image-dired)
 
 (defcustom image-dired-cmd-create-temp-image-options
-  '("-size" "%wx%h" "%f[0]" "-resize" "%wx%h>" "-strip" "jpeg:%t")
+  ;;; The `-flatten` argument makes a transparent PNG background white.
+  '("-size" "%wx%h" "%f[0]" "-resize" "%wx%h>" "-flatten" "-strip" "jpeg:%t")
   "Options of command used to create temporary image for display window.
 Used together with `image-dired-cmd-create-temp-image-program',
 Available format specifiers are: %w and %h which are replaced by
@@ -335,6 +338,37 @@ Available format specifiers are the same as in
   :type '(repeat (string :tag "Argument"))
   :group 'image-dired)
 
+(defcustom image-dired-cmd-create-standard-thumbnail-command
+  (concat
+   image-dired-cmd-create-thumbnail-program " "
+   "-size %wx%h \"%f\" "
+   (unless (or image-dired-cmd-pngcrush-program image-dired-cmd-pngnq-program)
+     (concat
+      "-set \"Thumb::MTime\" \"%m\" "
+      "-set \"Thumb::URI\" \"file://%f\" "
+      "-set \"Description\" \"Thumbnail of file://%f\" "
+      "-set \"Software\" \"" (emacs-version) "\" "))
+   "-thumbnail \"%wx%h>\" png:\"%t\""
+   (if image-dired-cmd-pngnq-program
+       (concat
+        " ; " image-dired-cmd-pngnq-program " -f \"%t\""
+        (unless image-dired-cmd-pngcrush-program
+          " ; mv %q %t")))
+   (if image-dired-cmd-pngcrush-program
+       (concat
+        (unless image-dired-cmd-pngcrush-program
+          " ; cp %t %q")
+        " ; " image-dired-cmd-pngcrush-program " -q "
+        "-text b \"Description\" \"Thumbnail of file://%f\" "
+        "-text b \"Software\" \"" (emacs-version) "\" "
+        "-text b \"Thumb::MTime\" \"%m\" "
+        "-text b \"Thumb::URI\" \"file://%f\" "
+        "%q %t"
+        " ; rm %q")))
+  "Command to create thumbnails according to the Thumbnail Managing Standard."
+  :type 'string
+  :group 'image-dired)
+
 (defcustom image-dired-cmd-rotate-thumbnail-program
   "mogrify"
   "Executable used to rotate thumbnail.
@@ -450,6 +484,18 @@ and `image-dired-thumb-height'."
   :type 'integer
   :group 'image-dired)
 
+(defcustom image-dired-thumb-width--dired-buffer
+  (if (eq 'standard image-dired-thumbnail-storage) 128 50)
+  "Width of thumbnails, in pixels -- in the `dired-buffer'."
+  :type 'integer
+  :group 'image-dired)
+
+(defcustom image-dired-thumb-height--dired-buffer
+  (if (eq 'standard image-dired-thumbnail-storage) 128 50)
+  "Height of thumbnails, in pixels -- in the `dired-buffer'."
+  :type 'integer
+  :group 'image-dired)
+
 (defcustom image-dired-thumb-relief 2
   "Size of button-like border around thumbnails."
   :type 'integer
@@ -585,19 +631,65 @@ Create the thumbnails directory if it does not exist."
 (defun image-dired-get-thumbnail-image (file)
   "Return the image descriptor for a thumbnail of image file FILE."
   (unless (string-match (image-file-name-regexp) file)
-    (error "%s is not a valid image file" file))
-  (let* ((thumb-file (image-dired-thumb-name file))
-	 (thumb-attr (file-attributes thumb-file)))
-    (when (or (not thumb-attr)
-	      (time-less-p (file-attribute-modification-time thumb-attr)
-			   (file-attribute-modification-time
-			    (file-attributes file))))
-      (image-dired-create-thumb file thumb-file))
-    (create-image thumb-file)
-;;     (list 'image :type 'jpeg
-;;           :file thumb-file
-;; 	  :relief image-dired-thumb-relief :margin image-dired-thumb-margin)
-    ))
+    (let ((debug-on-quit nil)
+          (msg (format "%s is not a valid image file." file)))
+      (signal 'quit `(,msg))))
+  (cond
+    ((and (not (string-match "\\.\\(PDF\\)\\'" file))
+          (string-match (image-file-name-regexp) file))
+      (let* ((thumb-name (image-dired-thumb-name file))
+             (thumbnail-dimensions
+               (when (file-exists-p thumb-name)
+                 (image-dimensions thumb-name))))
+        (if (and
+               ;;; The goal is to move on to `image-dired-create-thumb' IF
+               ;;; the thumbnail exists and is the wrong size, or it does not exist.
+               (or (and (file-exists-p thumb-name)
+                        (not (or (= image-dired-thumb-width
+                                    (car thumbnail-dimensions))
+                                 (= image-dired-thumb-height
+                                    (cdr thumbnail-dimensions))))
+                        ;;; If source file is newer, then we need a new thumbnail.
+                        (<= (float-time (nth 5 (file-attributes file)))
+                            (float-time (nth 5 (file-attributes thumb-name))))
+                        (progn
+                          (clear-image-cache)
+                          'create-new-image))
+                   ;;; If the file does not exist, of course, we need to create it!
+                   (not (file-exists-p thumb-name)))
+               (not (= 0 (image-dired-create-thumb file thumb-name))))
+          (message "Thumb could not be created for file %s" file)
+          (create-image thumb-name))))
+    ((string-match "\\.\\(PDF\\)\\'" file)
+      ;;; convert source.pdf[0] output.jpeg
+      ;;; You can also select ranges, e.g., using source.pdf[0-3].
+      ;;; convert -density 300 a.pdf[0] -resize 5% a.png
+      (let* ((absolute-basename (file-name-sans-extension file))
+             (png-filename (concat absolute-basename ".png"))
+             (thumb-name (image-dired-thumb-name png-filename))
+             (thumbnail-dimensions
+               (when (file-exists-p thumb-name)
+                 (image-dimensions thumb-name))))
+        (if (and
+               ;;; The goal is to move on to `image-dired-create-thumb' IF
+               ;;; the thumbnail exists and is the wrong size, or it does not exist.
+               (or (and (file-exists-p thumb-name)
+                        (not (or (= image-dired-thumb-width
+                                    (car thumbnail-dimensions))
+                                 (= image-dired-thumb-height
+                                    (cdr thumbnail-dimensions))))
+                        ;;; If source file is newer, then we need a new thumbnail.
+                        (<= (float-time (nth 5 (file-attributes file)))
+                            (float-time (nth 5 (file-attributes thumb-name))))
+                        (progn
+                          (clear-image-cache)
+                          'create-new-image))
+                   (not (file-exists-p thumb-name)))
+               (not (= 0 (image-dired-create-thumb file thumb-name))))
+            (message "Thumb could not be created for file %s" file)
+          (create-image thumb-name))))
+    (t
+      (message "%s does not match `image-file-name-regexp'" file))))
 
 (defun image-dired-insert-thumbnail (file original-file-name
                                      associated-dired-buffer)
@@ -824,11 +916,32 @@ Queued items live in `image-dired-queue'."
     (apply #'image-dired-create-thumb-1 (pop image-dired-queue))))
 
 (defun image-dired-create-thumb (original-file thumbnail-file)
-  "Add a job for generating thumbnail to `image-dired-queue'."
-  (setq image-dired-queue
-        (nconc image-dired-queue
-               (list (list original-file thumbnail-file))))
-  (run-at-time 0 nil #'image-dired-thumb-queue-run))
+  "For ORIGINAL-FILE, create thumbnail image named THUMBNAIL-FILE."
+  (let* ((width (number-to-string image-dired-thumb-width))
+         (height (number-to-string image-dired-thumb-height))
+         (modif-time (format "%.0f" (float-time (nth 5 (file-attributes
+                                                        original-file)))))
+         (thumbnail-nq8-file (replace-regexp-in-string ".png\\'" "-nq8.png"
+                                                       thumbnail-file))
+         (command
+          (format-spec
+           (if (eq 'standard image-dired-thumbnail-storage)
+               image-dired-cmd-create-standard-thumbnail-command
+             image-dired-cmd-create-thumbnail-options)
+           (list
+            (cons ?p image-dired-cmd-create-thumbnail-program)
+            (cons ?w width)
+            (cons ?h height)
+            (cons ?m modif-time)
+            (cons ?f original-file)
+            (cons ?q thumbnail-nq8-file)
+            (cons ?t thumbnail-file))))
+         thumbnail-dir)
+    (when (not (file-exists-p
+                (setq thumbnail-dir (file-name-directory thumbnail-file))))
+      (message "Creating thumbnail directory.")
+      (make-directory thumbnail-dir))
+    (call-process shell-file-name nil nil nil shell-command-switch command)))
 
 ;;;###autoload
 (defun image-dired-dired-toggle-marked-thumbs (&optional arg)
@@ -839,26 +952,31 @@ of the marked files.  If ARG is an integer, use the next ARG (or
 previous -ARG, if ARG<0) files."
   (interactive "P")
   (dired-map-over-marks
-   (let ((image-pos  (dired-move-to-filename))
-         (image-file (dired-get-filename nil t))
-         thumb-file
-         overlay)
-     (when (and image-file
-                (string-match-p (image-file-name-regexp) image-file))
-       (setq thumb-file (image-dired-get-thumbnail-image image-file))
-       ;; If image is not already added, then add it.
-       (let ((thumb-ov (cl-loop for ov in (overlays-in (point) (1+ (point)))
-                                if (overlay-get ov 'thumb-file) return ov)))
-         (if thumb-ov
-             (delete-overlay thumb-ov)
-	   (put-image thumb-file image-pos)
-	   (setq overlay
-                 (cl-loop for ov in (overlays-in (point) (1+ (point)))
-                          if (overlay-get ov 'put-image) return ov))
-	   (overlay-put overlay 'image-file image-file)
-	   (overlay-put overlay 'thumb-file thumb-file)))))
-   arg             ; Show or hide image on ARG next files.
-   'show-progress) ; Update dired display after each image is updated.
+    (let ((image-dired-thumb-width image-dired-thumb-width--dired-buffer)
+          (image-dired-thumb-height image-dired-thumb-height--dired-buffer)
+          (image-pos  (dired-move-to-filename))
+          (image-file (dired-get-filename nil t))
+          (case-fold-search t)
+          thumb-file overlay)
+      (when (and image-file
+                 (image-file-name-regexp) image-file)
+        (setq thumb-file (image-dired-get-thumbnail-image image-file))
+        ;; If image is not already added, then add it.
+        (let* ((cur-ovs (overlays-in (point) (1+ (point))))
+               (thumb-ov (car (cl-remove-if-not
+                                (lambda (ov) (overlay-get ov 'thumb-file))
+                                cur-ovs))))
+          (if thumb-ov
+              (delete-overlay thumb-ov)
+      (put-image thumb-file image-pos)
+      (setq overlay
+                  (cl-loop for o in (overlays-in (point) (1+ (point)))
+                           when (overlay-get o 'put-image) collect o into ov
+                           finally return (car ov)))
+      (overlay-put overlay 'image-file image-file)
+      (overlay-put overlay 'thumb-file thumb-file)))))
+    arg             ; Show or hide image on ARG next files.
+    'show-progress) ; Update dired display after each image is updated.
   (add-hook 'dired-after-readin-hook
             'image-dired-dired-after-readin-hook nil t))
 
@@ -993,6 +1111,16 @@ Restore any changes to the window configuration made by calling
       (set-window-configuration image-dired-saved-window-configuration)
     (message "No saved window configuration")))
 
+(defun image-dimensions (filename)
+  (let* ((raw-dimensions
+           (shell-command-to-string
+             (concat image-dired-cmd-create-thumbnail-program " " (prin1-to-string filename) " -ping -format \"%w x %h\" info:")))
+         (list-dimensions
+           (delete "x" (split-string raw-dimensions))))
+    (cons
+      (string-to-number (car list-dimensions))
+      (string-to-number (cadr list-dimensions)))))
+
 ;;;###autoload
 (defun image-dired-display-thumbs (&optional arg append do-not-pop)
   "Display thumbnails of all marked files, in `image-dired-thumbnail-buffer'.
@@ -1016,7 +1144,7 @@ used or not.  If non-nil, use `display-buffer' instead of
 thumbnail buffer to be selected."
   (interactive "P")
   (let ((buf (image-dired-create-thumbnail-buffer))
-        thumb-name files dired-buf)
+        files dired-buf)
     (if arg
         (setq files (list (dired-get-filename)))
       (setq files (dired-get-marked-files)))
@@ -1027,10 +1155,55 @@ thumbnail buffer to be selected."
             (erase-buffer)
           (goto-char (point-max)))
         (dolist (curr-file files)
-          (setq thumb-name (image-dired-thumb-name curr-file))
-          (when (not (file-exists-p thumb-name))
-            (image-dired-create-thumb curr-file thumb-name))
-          (image-dired-insert-thumbnail thumb-name curr-file dired-buf)))
+           (cond
+             ((and (not (string-match "\\.\\(PDF\\)\\'" curr-file))
+                   (string-match (image-file-name-regexp) curr-file))
+               (let* ((thumb-name (image-dired-thumb-name curr-file))
+                      (thumbnail-dimensions
+                        (when (file-exists-p thumb-name)
+                          (image-dimensions thumb-name))))
+                 (if (and
+                        ;;; The goal is to move on to `image-dired-create-thumb' IF
+                        ;;; the thumbnail exists and is the wrong size, or it does not exist.
+                        (or (and (file-exists-p thumb-name)
+                                 (not (or (= image-dired-thumb-width
+                                             (car thumbnail-dimensions))
+                                          (= image-dired-thumb-height
+                                             (cdr thumbnail-dimensions))))
+                                 (progn
+                                   (clear-image-cache)
+                                   'create-new-image))
+                            (not (file-exists-p thumb-name)))
+                        (not (= 0 (image-dired-create-thumb curr-file thumb-name))))
+                   (message "Thumb could not be created for file %s" curr-file)
+                   (image-dired-insert-thumbnail thumb-name curr-file dired-buf))))
+             ((string-match "\\.\\(PDF\\)\\'" curr-file)
+               ;;; convert source.pdf[0] output.jpeg
+               ;;; You can also select ranges, e.g., using source.pdf[0-3].
+               ;;; convert -density 300 a.pdf[0] -resize 5% a.png
+               (let* ((absolute-basename (file-name-sans-extension curr-file))
+                      (png-filename (concat absolute-basename ".png"))
+                      (thumb-name (image-dired-thumb-name png-filename))
+                      (thumbnail-dimensions
+                        (when (file-exists-p thumb-name)
+                          (image-dimensions thumb-name))))
+                 (if (and
+                        ;;; The goal is to move on to `image-dired-create-thumb' IF
+                        ;;; the thumbnail exists and is the wrong size, or it does not exist.
+                        (or (and (file-exists-p thumb-name)
+                                 (not (or (= image-dired-thumb-width
+                                             (car thumbnail-dimensions))
+                                          (= image-dired-thumb-height
+                                             (cdr thumbnail-dimensions))))
+                                 (progn
+                                   (clear-image-cache)
+                                   'create-new-image))
+                            (not (file-exists-p thumb-name)))
+                        (not (= 0 (image-dired-create-thumb curr-file thumb-name))))
+                     (message "Thumb could not be created for file %s" curr-file)
+                   (image-dired-insert-thumbnail thumb-name curr-file dired-buf))))
+             (t
+               (message "%s does not match `image-file-name-regexp'" curr-file)))))
       (if do-not-pop
           (display-buffer buf)
         (pop-to-buffer buf))
diff --git a/lisp/image-file.el b/lisp/image-file.el
index 6f4ee7a..59d352b 100644
--- a/lisp/image-file.el
+++ b/lisp/image-file.el
@@ -36,7 +36,7 @@
 
 ;;;###autoload
 (defcustom image-file-name-extensions
-  (purecopy '("png" "jpeg" "jpg" "gif" "tiff" "tif" "xbm" "xpm" "pbm" "pgm" "ppm" "pnm" "svg"))
+  (purecopy '("png" "jpeg" "jpg" "gif" "tiff" "tif" "xbm" "xpm" "pbm" "pgm" "ppm" "pnm" "svg" "pdf"))
   "A list of image-file filename extensions.
 Filenames having one of these extensions are considered image files,
 in addition to those matching `image-file-name-regexps'.
