You are not logged in.
Hi everybody,
I'm using ranger as my preferred file manager. The default configuration shows PDF file previews as plaintext. However, I'd like to preview them as images, as described here.
So I copied the default configuration to ~/.config/ranger with ranger --copy-config=all and pasted this piece in scope.sh:
# Image previews, if enabled in ranger.
if [ "$preview_images" = "True" ]; then
case "$mimetype" in
application/pdf)
pdftoppm -jpeg -singlefile "$path" "${cached//.jpg}" && exit 6;;
esac
fiI've commented out the text preview part for PDF files further in scope.sh.
This doesn't preview PDF files as images properly. Instead, I get what looks like the pdf source in plaintext:
%PDF-1.4
%äüöß
2 0 obj
<</Length 3 0 R/Filter/FlateDecode>>
<gibberish>I think that the piece of code should be edited a bit. I thought of conforming to the ffmpegthumbnailer preview method which is commented out in the default scope.sh:
ffmpegthumbnailer -i "$path" -o "$cached" -s 0 && exit 6 || exit 1;;so maybe the pdftoppm code should be something like:
pdftoppm -jpeg -singlefile "$path" "$cached" && exit 6 || exit 1;;However, this doesn't work properly either. Taking a quick look at ~/.config/ranger shows me that the previews are being rendered correctly, but they have double extensions, which could be the real problem:
0e793676c96ba13ab7a24100c6c8f1fc4070b6c5.jpg.jpg
1d823459ffdcfe1a8b4a99d9bac1983e1b54d54b.jpg.jpg
2dc60f15d3b658ae8ef77d91408ec5d73a38e925.jpg.jpg
4be12ce99abb25b5031325ce99dffa37c10b61ba.jpg.jpg
4d1427f9d7f09b7540a09541f03b567e1798b0bc.jpg.jpg
6f44024181a1308e358c6dc6e5023e29bd0575bd.jpg.jpg
64cd8324924e5c2ec901c0c9ce192b7f47b676c2.jpg.jpg
66bafffa78f190b21cd1f1435b9bd0613aa432fd.jpg.jpg
99db6af412e5b0f1c62aa1cfb2cab95784e1ebec.jpg.jpg
1426a57041b451e6b19184daf5b963aaeaffef7c.jpg.jpg
492169b452c55df13412b554798c80adfef32bdd.jpg.jpg
a0aa5b10ac2c77f25cfe8fe367e83b4dc16157ba.jpg.jpg
a7fd10925cc45361e2c0a021aeabd79fd346dfc9.jpg.jpg
a929a3b7abccd6f5fea82537208d81d5af25e5d9.jpg.jpg
d67f2889b4e053e072332986266ea0fc1b1919de.jpg.jpg
d7309bef9a659229b4815da0542968436a4f5b35.jpg.jpg
eca78fe71567b878d474765208642763ec5e44c2.jpg.jpg
eccdd6015f070570d3602c9f8dde53b92012d871.jpg.jpgDo you have any idea on how to fix this?
Last edited by Exeleration-G (2017-06-11 08:29:41)
Offline
Alright, I found a fix myself:
First off, after you've changed some code, don't forget to clear all files in ~/.cache/ranger to force ranger to generate new previews.
Now, for the code:
# Image previews, if enabled in ranger.
if [ "$preview_images" = "True" ]; then
case "$mimetype" in
application/pdf)
evince-thumbnailer -s 400 "$path" "$cached" && exit 6;;
esac
fiLast edited by Exeleration-G (2017-06-10 20:45:28)
Offline