From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Keith David Bershatsky Newsgroups: gmane.emacs.bugs Subject: bug#26432: Acknowledgement (image-dired: Adding support for PDF thumbnails.) Date: Mon, 10 Apr 2017 21:01:50 -0700 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Trace: blaine.gmane.org 1491883333 24280 195.159.176.226 (11 Apr 2017 04:02:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 11 Apr 2017 04:02:13 +0000 (UTC) To: 26432@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Apr 11 06:02:10 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cxn0L-0006EI-2s for geb-bug-gnu-emacs@m.gmane.org; Tue, 11 Apr 2017 06:02:09 +0200 Original-Received: from localhost ([::1]:37160 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxn0R-0005Rq-4V for geb-bug-gnu-emacs@m.gmane.org; Tue, 11 Apr 2017 00:02:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46581) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxn0I-0005QO-B3 for bug-gnu-emacs@gnu.org; Tue, 11 Apr 2017 00:02:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cxn0F-00035I-7E for bug-gnu-emacs@gnu.org; Tue, 11 Apr 2017 00:02:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:43633) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cxn0E-000351-VJ for bug-gnu-emacs@gnu.org; Tue, 11 Apr 2017 00:02:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cxn0E-0006hY-Fs for bug-gnu-emacs@gnu.org; Tue, 11 Apr 2017 00:02:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Keith David Bershatsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 11 Apr 2017 04:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26432 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 26432-submit@debbugs.gnu.org id=B26432.149188331825750 (code B ref 26432); Tue, 11 Apr 2017 04:02:02 +0000 Original-Received: (at 26432) by debbugs.gnu.org; 11 Apr 2017 04:01:58 +0000 Original-Received: from localhost ([127.0.0.1]:41832 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cxn09-0006hG-NF for submit@debbugs.gnu.org; Tue, 11 Apr 2017 00:01:57 -0400 Original-Received: from gateway24.websitewelcome.com ([192.185.51.162]:14380) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cxn06-0006h2-3n for 26432@debbugs.gnu.org; Tue, 11 Apr 2017 00:01:54 -0400 Original-Received: from cm3.websitewelcome.com (unknown [108.167.139.23]) by gateway24.websitewelcome.com (Postfix) with ESMTP id 4DA0816664 for <26432@debbugs.gnu.org>; Mon, 10 Apr 2017 23:01:53 -0500 (CDT) Original-Received: from gator3053.hostgator.com ([50.87.144.69]) by cm3.websitewelcome.com with id 6s1r1v0171W3Awq01s1tk7; Mon, 10 Apr 2017 23:01:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lawlist.com ; s=default; h=Content-Type:MIME-Version:Subject:To:From:Message-ID:Date: Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Kp4DZrAnNwrybgkezeh5QaRwW/CzYRH7wsgHDvoMFPs=; b=OyiK8gOVQtunuN0YsdxIZuVFOI jj5VMCVDWlaSukMLxsvMeamGJQC39i6S+kn7XygbtoQcJw8ig4eUbCTWavbgoUNh9M3wUg4e9ldOL hHDw6MHCML9z/RaHAc1INTkjj5XsMrymnByUDPiYiynnayAmjIciDlAb4/lEA7ZuduopjFdyOwf0r M9RjvfaY8htjXu+nBinbN/ea+zLo5EP2c4O7gt0/XvArtF6BnTK/VaXhV8U/COqjJZOshoQd/nZie 76vfofiR5tNqGQoafj+9aHLx19tPCht4L7XGow4iw9CwQ08pkM9grL41PENDhsZT2IHjIzsAnuVxv JNIyYr4Q==; Original-Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:56981 helo=server.local) by gator3053.hostgator.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.87) (envelope-from ) id 1cxn03-000XTw-Cv for 26432@debbugs.gnu.org; Mon, 10 Apr 2017 23:01:51 -0500 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3053.hostgator.com X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lawlist.com X-BWhitelist: no X-Source-IP: 45.48.239.195 X-Exim-ID: 1cxn03-000XTw-Cv X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: cpe-45-48-239-195.socal.res.rr.com (server.local) [45.48.239.195]:56981 X-Source-Auth: lawlist X-Email-Count: 1 X-Source-Cap: bGF3bGlzdDtsYXdsaXN0O2dhdG9yMzA1My5ob3N0Z2F0b3IuY29t X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:131456 Archived-At: In my own setup, I added the ability to detect the image size of the thumbnails and compare it to the current value of the image-dired width/height variables so that a new thumbnail will be created if the width/height of a stored cache thumbnail is different the current call. For example, multiple thumbnails might be 100 pixels, but perhaps I want to see an 800 thumbnail of just the selected file. This modification enables me to change the thumbnail image programmatically: (defun image-dimensions (filename) (let* ((convert-program image-dired-cmd-create-thumbnail-program) (raw-dimensions (shell-command-to-string (concat convert-program " " "\"" 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))))) ;;; ALTERNATIVE VERSION: (defun image-dired-display-thumbs (&optional arg append do-not-pop) "Display thumbnails of all marked files, in `image-dired-thumbnail-buffer'. If a thumbnail image does not exist for a file, it is created on the fly. With prefix argument ARG, display only thumbnail for file at point (this is useful if you have marked some files but want to show another one). Recommended usage is to split the current frame horizontally so that you have the dired buffer in the left window and the `image-dired-thumbnail-buffer' buffer in the right window. With optional argument APPEND, append thumbnail to thumbnail buffer instead of erasing it first. Optional argument DO-NOT-POP controls if `pop-to-buffer' should be used or not. If non-nil, use `display-buffer' instead of `pop-to-buffer'. This is used from functions like `image-dired-next-line-and-display' and `image-dired-previous-line-and-display' where we do not want the thumbnail buffer to be selected." (interactive "P") (let ((buf (image-dired-create-thumbnail-buffer)) thumb-name files dired-buf) (if arg (setq files (list (dired-get-filename))) (setq files (dired-get-marked-files))) (setq dired-buf (current-buffer)) (with-current-buffer buf (let ((inhibit-read-only t)) (if (not append) (erase-buffer) (goto-char (point-max))) (mapc (lambda (curr-file) (cond ((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) (let* ((absolute-basename (file-name-sans-extension curr-file)) (png-filename (concat absolute-basename ".png")) (pdf-first-page-filename (concat curr-file "[0]")) (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 pdf-first-page-filename thumb-name)))) (message "Thumb could not be created for file %s" pdf-first-page-filename) (image-dired-insert-thumbnail thumb-name pdf-first-page-filename dired-buf)))) (t (message "%s does not match `image-file-name-regexp'" curr-file)))) files)) (cond ((eq 'dynamic image-dired-line-up-method) (image-dired-line-up-dynamic)) ((eq 'fixed image-dired-line-up-method) (image-dired-line-up)) ((eq 'interactive image-dired-line-up-method) (image-dired-line-up-interactive)) ((eq 'none image-dired-line-up-method) nil) (t (image-dired-line-up-dynamic)))) (if do-not-pop (display-buffer image-dired-thumbnail-buffer) (pop-to-buffer image-dired-thumbnail-buffer))))