From d6cc99d96e5ea37b69123bf8fbfe3924c8f1976d Mon Sep 17 00:00:00 2001 From: Paweł Kraśnicki Date: Wed, 26 Dec 2018 21:15:31 +0100 Subject: scope.sh: Add DjVu previews (commented out) --- ranger/data/scope.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index 3f77bd28..6ff929d9 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -92,6 +92,11 @@ 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 @@ -99,6 +104,12 @@ handle_image() { # 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 @@ -122,7 +133,7 @@ handle_image() { # 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 \ -- cgit 1.4.1-2-gfad0 From c6786637c7d337dba73929cbdd066e38f0547855 Mon Sep 17 00:00:00 2001 From: Paweł Kraśnicki Date: Wed, 26 Dec 2018 21:16:17 +0100 Subject: scope.sh: Add ePub previews (commented out) --- ranger/data/scope.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index 6ff929d9..9adb5a84 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -140,6 +140,15 @@ handle_image() { # -- "${FILE_PATH}" "${IMAGE_CACHE_PATH%.*}" \ # && exit 6 || exit 1;; + # ePub. + # Needs . + # Alternative with more supported formats but more dependencies: + # . + # application/epub+zip) + # epub-thumbnailer \ + # "${FILE_PATH}" "${IMAGE_CACHE_PATH}" "${DEFAULT_SIZE%x*}" \ + # && exit 6 || exit 1;; + # Preview archives using the first image inside. # (Very useful for comic book collections for example.) # application/zip|application/x-rar|application/x-7z-compressed|\ -- cgit 1.4.1-2-gfad0 From 66605f383980f341280ad952b31f1418cb0f7794 Mon Sep 17 00:00:00 2001 From: Paweł Kraśnicki Date: Wed, 26 Dec 2018 21:17:43 +0100 Subject: scope.sh: Small refactor for robustness --- ranger/data/scope.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index 9adb5a84..fe4d032e 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 @@ -101,7 +101,7 @@ handle_image() { 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. @@ -130,6 +130,7 @@ 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 \ -- cgit 1.4.1-2-gfad0 From 2adfc18d9b081ac4834711660e00a9fba2d306c2 Mon Sep 17 00:00:00 2001 From: Paweł Kraśnicki Date: Thu, 27 Dec 2018 14:42:02 +0100 Subject: scope.sh: Minor code style change --- ranger/data/scope.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index fe4d032e..3ae9702f 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -107,7 +107,7 @@ handle_image() { # DjVu. # image/vnd.djvu) # ddjvu -format=tiff -quality=90 -page=1 -size="${DEFAULT_SIZE}" \ - # - "${IMAGE_CACHE_PATH}" <"${FILE_PATH}" \ + # - "${IMAGE_CACHE_PATH}" < "${FILE_PATH}" \ # && exit 6 || exit 1;; # Image -- cgit 1.4.1-2-gfad0 From 1667a60c6b356d5427c98ff37adea7f328e8ca5b Mon Sep 17 00:00:00 2001 From: toonn Date: Tue, 15 Jan 2019 00:54:05 +0100 Subject: Drop dots after file types --- ranger/data/scope.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index 3ae9702f..8bef068a 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -104,7 +104,7 @@ handle_image() { # convert -- "${FILE_PATH}" "${IMAGE_CACHE_PATH}" && exit 6 # exit 1;; - # DjVu. + # DjVu # image/vnd.djvu) # ddjvu -format=tiff -quality=90 -page=1 -size="${DEFAULT_SIZE}" \ # - "${IMAGE_CACHE_PATH}" < "${FILE_PATH}" \ @@ -141,7 +141,7 @@ handle_image() { # -- "${FILE_PATH}" "${IMAGE_CACHE_PATH%.*}" \ # && exit 6 || exit 1;; - # ePub. + # ePub # Needs . # Alternative with more supported formats but more dependencies: # . -- cgit 1.4.1-2-gfad0 From f9f73998a4792309f7b175d9e1d57dd5610fe132 Mon Sep 17 00:00:00 2001 From: Paweł Kraśnicki Date: Fri, 18 Jan 2019 18:05:31 +0100 Subject: scope.sh: Add Calibre e-book previews (commented out) --- ranger/data/scope.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index 8bef068a..13df2603 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -141,10 +141,12 @@ handle_image() { # -- "${FILE_PATH}" "${IMAGE_CACHE_PATH%.*}" \ # && exit 6 || exit 1;; - # ePub - # Needs . - # Alternative with more supported formats but more dependencies: - # . + # 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 ) # application/epub+zip) # epub-thumbnailer \ # "${FILE_PATH}" "${IMAGE_CACHE_PATH}" "${DEFAULT_SIZE%x*}" \ -- cgit 1.4.1-2-gfad0