ytfzf icon indicating copy to clipboard operation
ytfzf copied to clipboard

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

Open niksingh710 opened this issue 1 year ago • 4 comments

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.

niksingh710 avatar Sep 26 '24 21:09 niksingh710

I'm very excited that fzf has added this!

8637bc3

Euro20179 avatar Sep 27 '24 06:09 Euro20179

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 avatar Sep 28 '24 10:09 niksingh710

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.

niksingh710 avatar Sep 28 '24 10:09 niksingh710

Updated and working ytfzf project here: https://github.com/tabletseeker/ytfzf_prime

tabletseeker avatar Apr 28 '25 09:04 tabletseeker