Function: image-dired-pngnq-thumb

image-dired-pngnq-thumb is a byte-compiled function defined in image-dired-external.el.gz.

Signature

(image-dired-pngnq-thumb SPEC)

Documentation

Quantize thumbnail described by format SPEC with command pngnq.

Source Code

;; Defined in /usr/src/emacs/lisp/image/image-dired-external.el.gz
(defun image-dired-pngnq-thumb (spec)
  "Quantize thumbnail described by format SPEC with command `pngnq'."
  (let* ((snt
          (lambda (process status)
            (if (or (and (processp process) ; async case
                         (eq (process-status process) 'exit)
                         (zerop (process-exit-status process)))
                    (zerop status))     ; sync case
                ;; Pass off to pngcrush, or just rename the
                ;; THUMB-nq8.png file back to THUMB.png
                (if (and image-dired-cmd-pngcrush-program
                         (executable-find image-dired-cmd-pngcrush-program))
                    (image-dired-pngcrush-thumb spec)
                  (let ((nq8 (cdr (assq ?q spec)))
                        (thumb (cdr (assq ?t spec))))
                    (rename-file nq8 thumb t)))
              (if (processp process)
                  (message "command %S %s" (process-command process)
                           (string-replace "\n" "" status))))))
         (proc
          (let ((args (mapcar (lambda (arg) (format-spec arg spec))
                              image-dired-cmd-pngnq-options)))
            (if (eq system-type 'windows-nt)
                ;; Cannot safely use 'start-process' here, since awe
                ;; could be called to produce thumbnails for many
                ;; images, and we have a hard limitation of 32
                ;; simultaneous sub-processes on MS-Windows.
                (apply #'call-process
                       image-dired-cmd-pngnq-program nil nil nil args)
              (apply #'start-process
                     "image-dired-pngnq" nil
                     image-dired-cmd-pngnq-program args)))))
    (if (processp proc)
        (setf (process-sentinel proc) snt)
      (unless (zerop proc)
        (message "command %S failed" image-dired-cmd-pngnq-program))
      (funcall snt image-dired-cmd-pngnq-program proc))
    proc))