mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 20:01:27 +00:00
preview-tui-ext jpg previews (#905)
* switch to jpg previews * add ueberzug scaler
This commit is contained in:
parent
9544eb91d2
commit
bc59961d98
|
@ -224,19 +224,19 @@ preview_file () {
|
||||||
}
|
}
|
||||||
|
|
||||||
generate_preview() {
|
generate_preview() {
|
||||||
if [ ! -f "$TMPDIR/$3.png" ]; then
|
if [ ! -f "$TMPDIR/$3.jpg" ]; then
|
||||||
mkdir -p "$TMPDIR/${3%/*}"
|
mkdir -p "$TMPDIR/${3%/*}"
|
||||||
case $4 in
|
case $4 in
|
||||||
audio) ffmpeg -i "$3" "$TMPDIR/$3.png" -y >/dev/null 2>&1 ;;
|
audio) ffmpeg -i "$3" "$TMPDIR/$3.jpg" -y >/dev/null 2>&1 ;;
|
||||||
epub) gnome-epub-thumbnailer "$3" "$TMPDIR/$3.png" >/dev/null 2>&1 ;;
|
epub) gnome-epub-thumbnailer "$3" "$TMPDIR/$3.jpg" >/dev/null 2>&1 ;;
|
||||||
font) fontpreview -i "$3" -o "$TMPDIR/$3.png" >/dev/null 2>&1 ;;
|
font) fontpreview -i "$3" -o "$TMPDIR/$3.jpg" >/dev/null 2>&1 ;;
|
||||||
gif) if exists ueberzug || [ "$TERMINAL" = "kitty" ]; then
|
gif) if exists ueberzug || [ "$TERMINAL" = "kitty" ]; then
|
||||||
if [ ! -d "$TMPDIR/$3" ]; then
|
if [ ! -d "$TMPDIR/$3" ]; then
|
||||||
mkdir -p "$TMPDIR/$3"
|
mkdir -p "$TMPDIR/$3"
|
||||||
convert -coalesce "$3" "$TMPDIR/$3/${3##*/}.png"
|
convert -coalesce "$3" "$TMPDIR/$3/${3##*/}.jpg"
|
||||||
fi
|
fi
|
||||||
while true; do
|
while true; do
|
||||||
for frame in $(find "$TMPDIR/$3"/*.png | sort -V); do
|
for frame in $(find "$TMPDIR/$3"/*.jpg | sort -V); do
|
||||||
image_preview "$1" "$2" "$frame"
|
image_preview "$1" "$2" "$frame"
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
done
|
done
|
||||||
|
@ -248,15 +248,15 @@ generate_preview() {
|
||||||
image_preview "$1" "$2" "$3"
|
image_preview "$1" "$2" "$3"
|
||||||
return
|
return
|
||||||
fi ;;
|
fi ;;
|
||||||
office) libreoffice --convert-to png "$3" --outdir "$TMPDIR/${3%/*}" > /dev/null 2>&1
|
office) libreoffice --convert-to jpg "$3" --outdir "$TMPDIR/${3%/*}" > /dev/null 2>&1
|
||||||
filename="$(echo "${3##*/}" | cut -d. -f1)"
|
filename="$(echo "${3##*/}" | cut -d. -f1)"
|
||||||
mv "$TMPDIR/${3%/*}/$filename.png" "$TMPDIR/$3.png" ;;
|
mv "$TMPDIR/${3%/*}/$filename.jpg" "$TMPDIR/$3.jpg" ;;
|
||||||
pdf) pdftoppm -png -f 1 -singlefile "$3" "$TMPDIR/$3" >/dev/null 2>&1 ;;
|
pdf) pdftoppm -jpeg -f 1 -singlefile "$3" "$TMPDIR/$3" >/dev/null 2>&1 ;;
|
||||||
video) ffmpegthumbnailer -i "$3" -o "$TMPDIR/$3.png" -s 0 -q 10 >/dev/null 2>&1 ;;
|
video) ffmpegthumbnailer -i "$3" -o "$TMPDIR/$3.jpg" -s 0 -q 10 >/dev/null 2>&1 ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
if [ -f "$TMPDIR/$3.png" ]; then
|
if [ -f "$TMPDIR/$3.jpg" ]; then
|
||||||
image_preview "$1" "$2" "$TMPDIR/$3.png"
|
image_preview "$1" "$2" "$TMPDIR/$3.jpg"
|
||||||
else
|
else
|
||||||
fifo_pager print_bin_info "$3"
|
fifo_pager print_bin_info "$3"
|
||||||
fi
|
fi
|
||||||
|
@ -282,7 +282,7 @@ image_preview() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ueberzug_layer() {
|
ueberzug_layer() {
|
||||||
printf '{"action": "add", "identifier": "nnn_ueberzug", "x": 0, "y": 0, "width": "%s", "height": "%s", "path": "%s"}\n' "$1" "$2" "$3" > "$FIFO_UEBERZUG"
|
printf '{"action": "add", "identifier": "nnn_ueberzug", "x": 0, "y": 0, "width": "%s", "height": "%s", "scaler": "fit_contain", "path": "%s"}\n' "$1" "$2" "$3" > "$FIFO_UEBERZUG"
|
||||||
}
|
}
|
||||||
|
|
||||||
ueberzug_remove() {
|
ueberzug_remove() {
|
||||||
|
|
Loading…
Reference in a new issue