Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

image previews #2

Open
luisdavim opened this issue Nov 3, 2019 · 7 comments
Open

image previews #2

luisdavim opened this issue Nov 3, 2019 · 7 comments
Labels
discussion The feature / idea is still under discussion

Comments

@luisdavim
Copy link

Any plans to add image previews?

@b33rcity
Copy link

b33rcity commented Nov 3, 2019

Create ~/.config/pistol/pistol.conf with the line

image/* <your image handling application>

eg., mine is image/* kitty +kitten icat %s

Although I did run into an issue when using this with ranger where the image was being shown at full size. Many of my images are larger than my screen, so all of ranger ends up being hidden. I don't actually know enough about how ranger passes parameters to kitty for image sizing to reproduce it for pistol.

@doronbehar
Copy link
Owner

Any plans to add image previews?

Just like Lf, I don't plan to support Image previews officially. I will keep this issue open so maybe someone will put his ideas here or something.

I will suggest though, maybe to try out Gnome sushi for this purpose.

@falsified
Copy link

hate to necrobump, but would like this also, really want to use LF fulltime but img previews are so convenient

@BachoSeven
Copy link

I use the scope script on Lf, but perhaps the method described by @b33rcity can be applied with the program I use for images which is chafa, which previews pics in ANSI/Unicode.

The relevant line in my dots is
image/*) chafa --fill=block --symbols=block -c 256 -s 80x"${HEIGHT}" "${FILE_PATH}" || exit 1;;

@doronbehar doronbehar added the discussion The feature / idea is still under discussion label Jun 5, 2020
@duganchen
Copy link
Contributor

duganchen commented Sep 21, 2020

I have a setup that assumes Kitty and has both image previews, and thumbnail previews for videos. Let me just share it.

pistol.conf:

video/* kitty_vidthumb %pistol-filename%                                                                                                                
image/* kitty +kitten icat %pistol-filename%

kitty_vidthumb:

#!/bin/sh
kitty +kitten icat --silent --transfer-mode=stream --stdin=no "$( vidthumb "$1")"

vidthumb:

#!/usr/bin/env bash

if ! [ -f "$1" ]; then
	exit 1
fi

if [[ "$(file -L -b --mime-type "$1")" != video/* ]]; then
	exit 1
fi

cache="$HOME/.cache/vidthumb"
index="$HOME/.cache/vidthumb/index.json"
movie="$(realpath "$1")"
thumbnail=""

mkdir -p "$cache"

if [ -f "$index" ]; then
	thumbnail="$(jq -r ". \"$movie\"" <"$index")"
	if [[ "$thumbnail" == "null" ]]; then
		thumbnail="$(uuidgen).jpg"
		json="$(jq -r --arg "$movie" "$thumbnail" ". + {\"$movie\": \"$thumbnail\"}" <"$index")"
		echo "$json" >"$index"
	fi
else
	thumbnail="$(uuidgen).jpg"
	echo "{\"$movie\": \"$thumbnail\"}" >"$index"
fi

if [ ! -f "$cache/$thumbnail" ]; then
	ffmpegthumbnailer -i "$movie" -o "$cache/$thumbnail" -s 0 2>/dev/null
fi

echo "$cache/$thumbnail"

The vidthumb script (which prints out the path to a movie's thumbnail, after first generating it, caching it in ~/.cache/vidthumb, and indexing it) uses jq, ffmpegthumbnailer and uuidgen.

@duganchen
Copy link
Contributor

duganchen commented Feb 7, 2021

I've set up a repository for this:
https://github.com/duganchen/kitty-pistol-previewer

If you just want image previews, the pistol.conf line is:

image/* kitty +kitten icat --silent --transfer-mode=stream --stdin=no %pistol-filename%

@niksingh710
Copy link

currently i am using this script for preview
may this help in implementation preview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion The feature / idea is still under discussion
Projects
None yet
Development

No branches or pull requests

7 participants