summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortoonn <toonn@toonn.io>2019-12-29 22:07:09 +0100
committertoonn <toonn@toonn.io>2019-12-29 22:07:09 +0100
commit407ef979427579cd6fd4b1fa97fe9c5b0eb99ef0 (patch)
treee5ff613de81cae6027cf03559330c81322fc76d8
parent5291bad4a87c76f9856b7a1bafc7f48e8bf8e19c (diff)
Clean up 3d model previews
Added more supported formats. Moved the section to `handle_image` because it generates image previews. Extracted the common functionality into a function.
-rwxr-xr-xranger/data/scope.sh50
1 files changed, 26 insertions, 24 deletions
diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh
index f2b9ff9c..154028af 100755
--- a/ranger/data/scope.sh
+++ b/ranger/data/scope.sh
@@ -67,8 +67,10 @@ handle_extension() {
## PDF
pdf)
## Preview as text conversion
- pdftotext -l 10 -nopgbrk -q -- "${FILE_PATH}" - | fmt -w "${PV_WIDTH}" && exit 5
- mutool draw -F txt -i -- "${FILE_PATH}" 1-10 | fmt -w "${PV_WIDTH}" && exit 5
+ pdftotext -l 10 -nopgbrk -q -- "${FILE_PATH}" - | \
+ fmt -w "${PV_WIDTH}" && exit 5
+ mutool draw -F txt -i -- "${FILE_PATH}" 1-10 | \
+ fmt -w "${PV_WIDTH}" && exit 5
exiftool "${FILE_PATH}" && exit 5
exit 1;;
@@ -97,28 +99,6 @@ handle_extension() {
python -m json.tool -- "${FILE_PATH}" && exit 5
;;
- ## 3D models
- ## OpenSCAD only supports png image output, and ${IMAGE_CACHE_PATH} is
- ## hardcoded as jpeg. So we make a tempfile.png and just move/rename it
- ## to jpg This works because image library is smart enough to handle it
- stl|off|dxf)
- [[ "${PV_IMAGE_ENABLED}" != 'True' ]] && exit 1
- openscad --colorscheme="${OPENSCAD_COLORSCHEME}" \
- --imgsize="${OPENSCAD_IMGSIZE/x/,}" \
- -o "/tmp/$(basename "${FILE_PATH}").png" \
- <(echo "import(\"${FILE_PATH}\");")
- mv "/tmp/$(basename "${FILE_PATH}").png" "${IMAGE_CACHE_PATH}" \
- && exit 6
- ;;
- scad|csg)
- [[ "${PV_IMAGE_ENABLED}" != 'True' ]] && exit 1
- openscad --colorscheme="${OPENSCAD_COLORSCHEME}" \
- --imgsize="${OPENSCAD_IMGSIZE/x/,}" \
- -o "/tmp/$(basename "${FILE_PATH}").png" "${FILE_PATH}"
- mv "/tmp/$(basename "${FILE_PATH}").png" "${IMAGE_CACHE_PATH}" \
- && exit 6
- ;;
-
## Direct Stream Digital/Transfer (DSDIFF)
dsf)
mediainfo "${FILE_PATH}" && exit 5
@@ -247,6 +227,28 @@ handle_image() {
# [ "$rar" ] || [ "$zip" ] && rm -- "${IMAGE_CACHE_PATH}"
# ;;
esac
+
+ # openscad_image() {
+ # TMPPNG="$(mktemp -t XXXXXX.png)"
+ # openscad --colorscheme="${OPENSCAD_COLORSCHEME}" \
+ # --imgsize="${OPENSCAD_IMGSIZE/x/,}" \
+ # -o "${TMPPNG}" "${1}"
+ # mv "${TMPPNG}" "${IMAGE_CACHE_PATH}"
+ # }
+
+ # case "${FILE_EXTENSION_LOWER}" in
+ # ## 3D models
+ # ## OpenSCAD only supports png image output, and ${IMAGE_CACHE_PATH}
+ # ## is hardcoded as jpeg. So we make a tempfile.png and just
+ # ## move/rename it to jpg. This works because image libraries are
+ # ## smart enough to handle it.
+ # csg|scad)
+ # openscad_image "${FILE_PATH}" && exit 6
+ # ;;
+ # 3mf|amf|dxf|off|stl)
+ # openscad_image <(echo "import(\"${FILE_PATH}\");") && exit 6
+ # ;;
+ # esac
}
handle_mime() {