From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#57961: 29.0.50; [PATCH] image-dired thumbnail generation fails for PDFs on macOS Date: Wed, 21 Sep 2022 06:09:31 -0700 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30875"; mail-complaints-to="usenet@ciao.gmane.io" To: Daniel =?UTF-8?Q?Mart=C3=ADn?= , 57961@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 21 15:59:41 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 1ob0GL-0007v9-7N for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 21 Sep 2022 15:59:41 +0200 Original-Received: from localhost ([::1]:39242 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ob0GK-0004WG-8C for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 21 Sep 2022 09:59:40 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oazUI-00018n-7y for bug-gnu-emacs@gnu.org; Wed, 21 Sep 2022 09:10:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33855) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oazUH-0001d6-Sm for bug-gnu-emacs@gnu.org; Wed, 21 Sep 2022 09:10:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oazUH-0007Dm-Nl for bug-gnu-emacs@gnu.org; Wed, 21 Sep 2022 09:10:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 21 Sep 2022 13:10:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57961 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 57961-submit@debbugs.gnu.org id=B57961.166376578027726 (code B ref 57961); Wed, 21 Sep 2022 13:10:01 +0000 Original-Received: (at 57961) by debbugs.gnu.org; 21 Sep 2022 13:09:40 +0000 Original-Received: from localhost ([127.0.0.1]:32933 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oazTv-0007D8-R4 for submit@debbugs.gnu.org; Wed, 21 Sep 2022 09:09:40 -0400 Original-Received: from mail-oa1-f45.google.com ([209.85.160.45]:39849) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oazTu-0007Cu-2c for 57961@debbugs.gnu.org; Wed, 21 Sep 2022 09:09:38 -0400 Original-Received: by mail-oa1-f45.google.com with SMTP id 586e51a60fabf-11e9a7135easo8936442fac.6 for <57961@debbugs.gnu.org>; Wed, 21 Sep 2022 06:09:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:to:subject:message-id:date:mime-version :references:in-reply-to:from:from:to:cc:subject:date; bh=1H9Vokjz+vnhGaSo5h8TfmajhOhBKwgtImi6ee+qWEI=; b=WysPDrf1TtkYgbE/GLocbo3tlVdB8hcTQjServ90ylrQl+OOIRHZI79MalH2c1r01V vtiulYpjmepTzZ1Zh6+FgE9s3E86maG+1cS9wln1iRUULc+O3msJWNYymeK0NdjY0C42 /rHejl1ELs43wxh/pXsLscUgI5JgGgJXygqqgskQLMIbbU93QHAPpcE3mpNWSwVO54bC SYj3z8xOZsgMLQj5GSyz6iEoDGqtRO0jTQ4fl9Pw83BybiuNsV9GkwZXbU/RAWLTTlbI EHp2JI7WpUwP9GsoAX4UI7TNFrfmc+bU6aix3OWpPzRvEZPqI8KQuVxuEvj2l/OWZuv+ HOtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:to:subject:message-id:date:mime-version :references:in-reply-to:from:x-gm-message-state:from:to:cc:subject :date; bh=1H9Vokjz+vnhGaSo5h8TfmajhOhBKwgtImi6ee+qWEI=; b=iPquLcZIj2CzPktNHP2DthLlmQLeeB/1H+hO2roPHj6YvdKeiMGxhSxQgLixNjCZfD 9Dq9OWjV015Q6Tpwcu0soJAvF2oz2WKnzjHN+BFqmiTXA7cBJ/tVEfXkS2BUrEa+1ODK Jf3ld5+spqAiAQ5zU1YRAcE0tzbmd8us8ae3s/VF99mMSgz6QuwDbwafSfp2uyF450UM bz6NLPh3ASBuxuGnIiL1pD+jtCmPN/i5b8pR4tkjlteO9n+YwV2D3+2iJNRKAfeLj4a4 KUTwzUfQVJ+dyoArQmwo57G6qo7WcuJ68eSCum2A1cIRQjUNx+Ovbt3/K1T+ucsO/Du3 6Fkg== X-Gm-Message-State: ACrzQf0C0nwDKFfB/cnUuhkVc9p7eVnGAF7+ydZqGBiJFbeH612Ldea5 k+u5KlaruM6cgpZ/cthBPanNh4J9mDwY50S3UNI= X-Google-Smtp-Source: AMsMyM7/1ZJbYaZ26wmlygsj0EKJrnuMDwX9QKAshvsPls7PhdN6+XfZrq33vFX2sVPKWMoT9/O7V0C9Z05JCMbxRuA= X-Received: by 2002:a05:6870:b508:b0:12d:1c59:90d9 with SMTP id v8-20020a056870b50800b0012d1c5990d9mr5001392oap.199.1663765772372; Wed, 21 Sep 2022 06:09:32 -0700 (PDT) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Wed, 21 Sep 2022 06:09:31 -0700 In-Reply-To: X-Hashcash: 1:20:220921:57961@debbugs.gnu.org::pCNvjdcorNndYcSs:3pL/ 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:243352 Archived-At: Daniel Mart=C3=ADn via "Bug reports for GNU Emacs, the Swiss army knife of text editors" writes: > I've created this patch so that PDF thumbnails get the correct JPG or > PNG extension. That fixes the problem on macOS, at least. Thanks for your testing and the patch! Some comments below: > 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)))) > + I don't think we need this when (memq image-dired-thumbnail-storage image-dired--thumbnail-standard-sizes) because the files are then already saved to, e.g.: ~/.cache/thumbnails/normal/790f6914e3e396bf1b63f20769bd531d.png > (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-dire= d-dir))) > (file-name-base f) > (if hash (concat "_" hash) "") > - (file-name-extension f)))) > + (image-dired-file-name-extension f)))) Given that we already hard-code the use of JPEG, perhaps we should just hard-code ".jpg" here too? Of course, that will break when users start messing with `image-dired-cmd-create-thumbnail-options' but on the other hand they are then on their own in any case. > ((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)))))) Same here.