summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorWojciech Siewierski <wojciech.siewierski@onet.pl>2019-01-26 00:50:46 +0100
committerWojciech Siewierski <wojciech.siewierski@onet.pl>2019-01-26 00:50:46 +0100
commitcab56031ccee7091d940a477b2269cd8e2210002 (patch)
treec7a99a1e329037cb28452fe48b8978df8209f561
parent505dd0b4d327d908e131930f45b8984426836833 (diff)
parentf9f73998a4792309f7b175d9e1d57dd5610fe132 (diff)
downloadranger-cab56031ccee7091d940a477b2269cd8e2210002.tar.gz
Merge branch 'more-previews' of https://github.com/pkkm/ranger
-rwxr-xr-xranger/data/scope.sh29
1 files changed, 26 insertions, 3 deletions
diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh
index cbcba40b..33666fcb 100755
--- a/ranger/data/scope.sh
+++ b/ranger/data/scope.sh
@@ -31,7 +31,7 @@ IMAGE_CACHE_PATH="${4}"  # Full path that should be used to cache image preview
 PV_IMAGE_ENABLED="${5}"  # 'True' if image previews are enabled, 'False' otherwise.
 
 FILE_EXTENSION="${FILE_PATH##*.}"
-FILE_EXTENSION_LOWER=$(echo ${FILE_EXTENSION} | tr '[:upper:]' '[:lower:]')
+FILE_EXTENSION_LOWER="$(printf "%s" "${FILE_EXTENSION}" | tr '[:upper:]' '[:lower:]')"
 
 # Settings
 HIGHLIGHT_SIZE_MAX=262143  # 256KiB
@@ -92,13 +92,24 @@ handle_extension() {
 }
 
 handle_image() {
+    # Size of the preview if there are multiple options or it has to be rendered
+    # from vector graphics. If the conversion program allows specifying only one
+    # dimension while keeping the aspect ratio, the width will be used.
+    local DEFAULT_SIZE="1920x1080"
+
     local mimetype="${1}"
     case "${mimetype}" in
         # SVG
         # image/svg+xml)
-        #     convert "${FILE_PATH}" "${IMAGE_CACHE_PATH}" && exit 6
+        #     convert -- "${FILE_PATH}" "${IMAGE_CACHE_PATH}" && exit 6
         #     exit 1;;
 
+        # DjVu
+        # image/vnd.djvu)
+        #     ddjvu -format=tiff -quality=90 -page=1 -size="${DEFAULT_SIZE}" \
+        #           - "${IMAGE_CACHE_PATH}" < "${FILE_PATH}" \
+        #           && exit 6 || exit 1;;
+
         # Image
         image/*)
             local orientation
@@ -119,16 +130,28 @@ handle_image() {
         #     # Thumbnail
         #     ffmpegthumbnailer -i "${FILE_PATH}" -o "${IMAGE_CACHE_PATH}" -s 0 && exit 6
         #     exit 1;;
+
         # PDF
         # application/pdf)
         #     pdftoppm -f 1 -l 1 \
-        #              -scale-to-x 1920 \
+        #              -scale-to-x "${DEFAULT_SIZE%x*}" \
         #              -scale-to-y -1 \
         #              -singlefile \
         #              -jpeg -tiffcompression jpeg \
         #              -- "${FILE_PATH}" "${IMAGE_CACHE_PATH%.*}" \
         #         && exit 6 || exit 1;;
 
+        # ePub, MOBI, FB2 (using Calibre)
+        # application/epub+zip|application/x-mobipocket-ebook|application/x-fictionbook+xml)
+        #     ebook-meta --get-cover="${IMAGE_CACHE_PATH}" -- "${FILE_PATH}" > /dev/null \
+        #         && exit 6 || exit 1;;
+
+        # ePub (using <https://github.com/marianosimone/epub-thumbnailer>)
+        # application/epub+zip)
+        #     epub-thumbnailer \
+        #         "${FILE_PATH}" "${IMAGE_CACHE_PATH}" "${DEFAULT_SIZE%x*}" \
+        #         && exit 6 || exit 1;;
+
         # Font
         application/font*|application/*opentype)
             preview_png="/tmp/$(basename "${IMAGE_CACHE_PATH%.*}").png"