pystardust / ytfzf

A posix script to find and watch youtube videos from the terminal. (Without API)
GNU General Public License v3.0
3.78k stars 345 forks source link

[Feature request]: Sixel Image Preview As now Fzf supports that. #749

Open niksingh710 opened 1 month ago

niksingh710 commented 1 month ago

Problem

Why do we need this feature? So that terminals having sixel support can easily show thumbnails.

Feature

Description of your proposed feature.

chafa -f sixel -s "''${FZF_PREVIEW_COLUMNS}x''${FZF_PREVIEW_LINES}" "$2" --animate false

This is the command i use in my fzf preview script to handle images.

Euro20179 commented 1 month ago

I'm very excited that fzf has added this!

8637bc3

niksingh710 commented 1 month ago

output

This is the issue i am facing.

The thumbnail size is slightly bigger than the size of fzf preview box. so fzf only renders bordered box and shows the image when the preview window is scrolled.

I guess reduction of the thumbnail dimensions would be a option to fix this

niksingh710 commented 1 month ago
diff --git a/ytfzf b/ytfzf
index 3da39ac..066f56c 100755
--- a/ytfzf
+++ b/ytfzf
@@ -2983,7 +2983,7 @@ preview_display_image() {
     chafa-sixel)
         printf '\n'
         command_exists "chafa" || die 3 "${new_line}chafa is not installed"
-        chafa -f sixel -s "${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}" "$thumb_path" 2>> "$thumbnail_debug_log" ;;
+        chafa -f sixel -s "${FZF_PREVIEW_COLUMNS}x$(( FZF_PREVIEW_LINES - 7 ))" "$thumb_path" 2>> "$thumbnail_debug_log" ;;
    catimg)
        printf '\n'
        command_exists "catimg" || die 3 "${new_line}catimg is not installed"

This patch fixes the issue.