kamiyaa / joshuto

ranger-like terminal file manager written in Rust
https://crates.io/crates/joshuto
GNU Lesser General Public License v3.0
3.34k stars 151 forks source link

XDG-thumb for preview & thumbs for non-image files #537

Closed DLFW closed 1 month ago

DLFW commented 2 months ago

This implements a cache for thumbnails and image previews for non-image file formats, like videos and PDFs. This patch extends the inbuilt image preview feature (285df85) by integrating the allmytoes crate and using its thumbnails instead of the actual file being previewed.

The image-preview feature uses the XDG-(freedesktop.org-) specified thumbnail-cache to re-use existing thumbs and to store newly created thumbs. (https://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html)

This increases performance for the image-preview because the preview does not need to load the full-sized version of the image and does not need to scale it down every time, once the thumbnail has been created. Also, thumbnails are now shared with other programs that use the XDG-thumb cache.

Furthermore, the new way to obtain thumbs allows to show image-previews for file types other than images. Existing thumbnails are shown for any file type. New thumbnails can be created for many video formats, PDF files, Postscript files, and SVGs. Users can also add “providers” for other file-types by configuring allmytoes.

The XDG-thumb feature can be disabled, and the thumbnail-size can be changed, both in joshuto.toml. The documentation has been extended, the whole image-preview page has been enhanced a little.

DLFW commented 2 months ago

Disclaimer: I'm the author of AllMyToes.

Two notes on this:

Clippy's failure in the pipeline seems not to be related to the changes in this PR but because of the latest Rust update to 1.78.0.