From: Stefan Kangas <stefankangas@gmail.com>
To: "Daniel Martín" <mardani29@yahoo.es>, 57961@debbugs.gnu.org
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 [thread overview]
Message-ID: <CADwFkmnsO-hYYyK7W17GMspspHzpC=kB+SJr00w3VEhSB7S0Sw@mail.gmail.com> (raw)
In-Reply-To: <m14jx1n4xs.fsf@yahoo.es>
Daniel Martín via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs@gnu.org> 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-dired-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.
next prev parent reply other threads:[~2022-09-21 13:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <m14jx1n4xs.fsf.ref@yahoo.es>
2022-09-20 20:53 ` bug#57961: 29.0.50; [PATCH] image-dired thumbnail generation fails for PDFs on macOS Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-21 11:42 ` Lars Ingebrigtsen
2022-09-21 13:09 ` Stefan Kangas [this message]
2022-09-21 13:58 ` Stefan Kangas
2022-09-28 10:45 ` Stefan Kangas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CADwFkmnsO-hYYyK7W17GMspspHzpC=kB+SJr00w3VEhSB7S0Sw@mail.gmail.com' \
--to=stefankangas@gmail.com \
--cc=57961@debbugs.gnu.org \
--cc=mardani29@yahoo.es \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.