GNU bug report logs -
#57961
29.0.50; [PATCH] image-dired thumbnail generation fails for PDFs on macOS
Previous Next
Reported by: Daniel Martín <mardani29 <at> yahoo.es>
Date: Tue, 20 Sep 2022 20:54:01 UTC
Severity: normal
Tags: patch
Found in version 29.0.50
Fixed in version 29.1
Done: Stefan Kangas <stefankangas <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #11 received at 57961 <at> debbugs.gnu.org (full text, mbox):
Daniel Martín via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs <at> 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.
This bug report was last modified 2 years and 235 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.