From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel =?UTF-8?Q?Mart=C3=ADn?= via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#57961: 29.0.50; [PATCH] image-dired thumbnail generation fails for PDFs on macOS Date: Tue, 20 Sep 2022 22:53:19 +0200 Message-ID: References: Reply-To: Daniel =?UTF-8?Q?Mart=C3=ADn?= Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20557"; mail-complaints-to="usenet@ciao.gmane.io" To: 57961@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 21 01:56:04 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oan5w-00058h-22 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 21 Sep 2022 01:56:04 +0200 Original-Received: from localhost ([::1]:39118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oan5u-0001Uh-W2 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 20 Sep 2022 19:56:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45464) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oakFn-000630-VY for bug-gnu-emacs@gnu.org; Tue, 20 Sep 2022 16:54:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60776) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oakFm-0006n0-6p for bug-gnu-emacs@gnu.org; Tue, 20 Sep 2022 16:54:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oakFl-0002C6-Pu for bug-gnu-emacs@gnu.org; Tue, 20 Sep 2022 16:54:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Daniel =?UTF-8?Q?Mart=C3=ADn?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 20 Sep 2022 20:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 57961 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16637072178399 (code B ref -1); Tue, 20 Sep 2022 20:54:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 20 Sep 2022 20:53:37 +0000 Original-Received: from localhost ([127.0.0.1]:59854 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oakFM-0002BP-Qv for submit@debbugs.gnu.org; Tue, 20 Sep 2022 16:53:37 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:45434) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oakFJ-0002BC-BK for submit@debbugs.gnu.org; Tue, 20 Sep 2022 16:53:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oakFI-0005O7-GA for bug-gnu-emacs@gnu.org; Tue, 20 Sep 2022 16:53:33 -0400 Original-Received: from sonic311-31.consmr.mail.ir2.yahoo.com ([77.238.176.163]:45716) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oakFE-0006gJ-LT for bug-gnu-emacs@gnu.org; Tue, 20 Sep 2022 16:53:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048; t=1663707202; bh=VNDQkMfeSg39FKZfoog+SqsSJ66tAeH5jMDsU8CSHKM=; h=From:To:Subject:Date:References:From:Subject:Reply-To; b=ABjuQZWQkpf90OVQbqJdL2KstDWYHEO4UZmXJ5fxtyd67Tp3w7RBtZ6KyKyFXK98I2Q3AOrY45B/lE9VSfMBy2LkzKTmtVm8gl6bZt/6psRowA55aH0IHt6otnhrBuxuadgB665wsFsYufG5bV9amg94H4pqcHILVbxr6ht4J9qpYmujMAyv1fgkjCF2dPyOm0g+PDOzhdOFUwY6gAFBqQIRqYWvCRRRgFbL/aC/7RVERRDYEzNBLrBj2oMpfmWKXGK7xpSTzRs8sm+DJowDUdqzvfaMGzOJDuedSlXNkxcYr7FVY7aGKNSTXReTBNG/v9Q2bh+hLCO851oZk4dupA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1663707202; bh=PjiPXd2RGA9WA1iC+9xzUL5rcP80O5G0AVGvsKeRlR6=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=EkUmCfI14TKJA8lxCPEnCDJUS28mxDmzYNPvFPEYX7CPSzLbwCz7m0i+Hu+JPLZJSpozUyhwXkHRHeoqCNK5OUx5mZnyYE+olt8RHSDhI1Fn4A3wRvEmfKwmirWLRCQF+EWyjkrJc8tj9oL6rF8Jm3lTfZB0zU4yJriLr0uGytGnli64YyZnZLWLNGej+N1qsn+HnW1EpaofbAlpFcrNKTb7rfWjL3EgHMQnGGM73yCl/F/pgrNChdLRnvwbbGttxnrYZuocvPlWTmkn2ERXDAq/pI56XLwHWqAFJiUYC6ROBVpZHPfYThK4A1CU1RuW/prRWhF/NCAu1YHx95sAwQ== X-YMail-OSG: 9eHzRJwVM1nVLvAujs6ebMvq.WIDQk4zzyGI3.u859nNi8ahYsMuwiu19ZBBeqY IW.PfUDid6mQEzKGUSr8HcoH4zO2KtgOK0lIr8blhveo9YMDoO0iybJEGUTRKCHmj7L.Pz4kaPnP _r352Gu9R4X4rUXCveg7VyDkBauI1bdGYg7zeUuxPA2hZUnxgDnoXQsxxY4SBlpEIyD3HIO6qdxp ZaYfg46N4AE_P6vq2M57XtyxoZpuFFUHyCqYEOJ2nzLTJXvqJ6RbE8k5M0cfWsR.H1la2s0PGMZv pW_Fsu2tz5sZVPHRUIeE2MlyD2btOZIH2RRYBG0JJimTdX7kYKW7Ay.MjiuewKCaK9.TRNowxGTt ppnub3pT7c_hM4q_JFeFqtBU3eKgK8XKS4_lsrlW7WPZncUDXZDxis6x0ATrMf.LQh7ilh6u6_nX JemZykRchasIrPYXJLHAULE1QddxavqCFy_9jW_aYeBGNwg_4pJJOO91jQorY35xD_gVfhPbZtul GDTXleMPTBOxsIoiJRrv8WSO.6hnGhQ.87CXoxnCOYA4nbFvyWU6B0BM9u.W0w.8SokTx..HasKW NCnxoLf2VC.2_2v1iHQKkHaswojCTV0r.TQ1lyUZ4v4TiGGA4yxuXVhqKPtVgmno5BgzutC.hM5w ut3RN0JmGfX9CB8ZmoHlYrPQESAM1_RTEVJhyFCx4GR9XM1L1zOSPoJ9gQh4hrJ52m5.w_xMPK1v 7aMdV3lX2OcQgCK6pctQYXECjq7pEc07zzIYtwdkhwbxiX8htjnpOfBOZm_rHY3tdp1huavJzFvc GMEbxzS5YzuJc9q8RpONCLKxBex5ywdC1mXmUwlgkj X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic311.consmr.mail.ir2.yahoo.com with HTTP; Tue, 20 Sep 2022 20:53:22 +0000 Original-Received: by hermes--production-ir2-6787885cb-wkhbw (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 6b74899f1404799fabd942eefa309415; Tue, 20 Sep 2022 20:53:20 +0000 (UTC) X-Mailer: WebService/1.1.20663 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=77.238.176.163; envelope-from=mardani29@yahoo.es; helo=sonic311-31.consmr.mail.ir2.yahoo.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:243251 Archived-At: --=-=-= Content-Type: text/plain I tried the new PDF thumbnail generation feature in image-dired and I got the following error in the macOS console, and the thumbnails are blank: CoreGraphics PDF has logged an error. Set environment variable "CG_PDF_VERBOSE" to learn more The reason seems to be that the thumbnails are actually JPG files, but they are created with PDF extension, so the image loading code in the NS port sees the extension and tries to search for a %PDF marker in the file, which always fails. I've created this patch so that PDF thumbnails get the correct JPG or PNG extension. That fixes the problem on macOS, at least. Any ideas if the logic is correct and makes sense? Thanks. In GNU Emacs 29.0.50 (build 3, aarch64-apple-darwin21.6.0, NS appkit-2113.60 Version 12.6 (Build 21G115)) of 2022-09-20 built on Daniels-MacBook-Pro.local Repository revision: 1231a601ebe1fd9fe454c504dbeb9267440242e7 Repository branch: master Windowing system distributor 'Apple', version 10.3.2113 System Description: macOS 12.6 Configured using: 'configure CPPFLAGS=-I/opt/homebrew/opt/openjdk@11/include' Configured features: ACL DBUS GLIB GNUTLS JSON LCMS2 LIBXML2 MODULES NOTIFY KQUEUE NS PDUMPER PNG RSVG SQLITE3 THREADS TOOLKIT_SCROLL_BARS WEBP XIM ZLIB Important settings: value of $LANG: en_ES.UTF-8 locale-coding-system: utf-8-unix Major mode: Messages Minor modes in effect: tooltip-mode: t global-eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t buffer-read-only: t line-number-mode: t indent-tabs-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message mailcap yank-media puny rfc822 mml mml-sec password-cache epa derived epg rfc6068 epg-config gnus-util text-property-search mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils time-date subr-x misearch multi-isearch format-spec vc-git diff-mode easy-mmode vc-dispatcher image-file image-converter dired-aux image-dired image-dired-tags image-dired-external image-dired-util image-mode wallpaper xdg exif cl-loaddefs cl-lib dired dired-loaddefs rmc iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/ns-win ns-win ucs-normalize mule-util term/common-win tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic indonesian philippine cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads dbusbind kqueue cocoa ns lcms2 multi-tty make-network-process emacs) Memory information: ((conses 16 82066 6542) (symbols 48 6208 0) (strings 32 19408 2168) (string-bytes 1 585126) (vectors 16 11857) (vector-slots 8 170638 10214) (floats 8 39 25) (intervals 56 5237 164) (buffers 1000 12)) --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-a-bug-where-PDF-thumbnails-were-stored-with-PDF-.patch >From 37583170eff4858b6bd288cc78e2ec967ee0073f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= Date: Tue, 20 Sep 2022 22:27:56 +0200 Subject: [PATCH] Fix a bug where PDF thumbnails were stored with PDF extension * lisp/image/image-dired-util.el (image-dired-file-name-extension): New function to compute the filename extension for a thumbnail. This new function ensures that the extension of a PDF thumbnail is either JPG or PNG. * lisp/image/image-dired-util.el (image-dired-thumb-name): Use the new function. --- lisp/image/image-dired-util.el | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lisp/image/image-dired-util.el b/lisp/image/image-dired-util.el index dcf0b22cfe..89513f9441 100644 --- a/lisp/image/image-dired-util.el +++ b/lisp/image/image-dired-util.el @@ -57,6 +57,19 @@ image-dired-dir (message "Thumbnail directory created: %s" image-dired-dir)) image-dired-dir)) +(defun image-dired-file-name-extension (file) + "Return the filename extension for thumbnail FILE. +Return the value of `file-name-extension', but for PDF files +return PNG or JPG, depending on the thumbnail storage +configuration." + (let ((extension (file-name-extension file))) + (cond ((string-equal extension "pdf") + (cond ((memq image-dired-thumbnail-storage + image-dired--thumbnail-standard-sizes) + "png") + (t "jpg"))) + (t extension)))) + (defun image-dired-thumb-name (file) "Return absolute file name for thumbnail FILE. Depending on the value of `image-dired-thumbnail-storage', the @@ -91,13 +104,13 @@ image-dired-thumb-name (file-name-as-directory (expand-file-name (image-dired-dir))) (file-name-base f) (if hash (concat "_" hash) "") - (file-name-extension f)))) + (image-dired-file-name-extension f)))) ((eq 'per-directory image-dired-thumbnail-storage) (let ((f (expand-file-name file))) (format "%s.image-dired/%s.thumb.%s" (file-name-directory f) (file-name-base f) - (file-name-extension f)))))) + (image-dired-file-name-extension f)))))) (defvar image-dired-thumbnail-buffer "*image-dired*" "Image-Dired's thumbnail buffer.") -- 2.34.1 --=-=-=--