-
Notifications
You must be signed in to change notification settings - Fork 65
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
Sixel and tmux passthrough over ssh not rendering jpegs, ignoring sizes, and other chaos #217
Comments
Hi, thanks for the report! It looks like there are a couple of interacting issues here.
tl;dr: Try with recent versions of the terminal and Chafa, and use If you find any issues with image scaling in the latest version, I can look at samples (to make it as clear as possible, you could try at 30x30 inside a terminal window that's 80x80). I'm interested in making this as frictionless as possible. |
Concerning tmux, I recall sixel support was added in v3.4. Though, I should note that the release notes say "if built with --enable-sixel"; so, you might wanna check with your package source. With this, I think it'll be a good idea to use |
I believe the tmux version can be determined via the @stevenwalton, do you mind confirming your tmux version and testing with |
@hpjansson, thanks, this is some good info. I'll give these things a try and report back. Regarding the Most of those variables do not exist for me. But re Kitty: I'm on
For re
If I have any skill in life, it is being unfortunate enough to walk into any possible bug haha. I appreciate this philosophy and the project. Being able to render images at all in the terminal is a big help these days.
To all: I was also doing some further testing and found yesterday that it appears sometimes jpgs work and sometimes they don't. I'm not sure exactly what the pattern is but I think it might be either the image size or filesize. I believe it has not worked for any of the images that I took from my phone. I did Would some examples help? |
Crashes are my highest priority - could you please file a new issue for this so we can follow up there? It could be a variant of #210, but it's hard to tell. FWIW I can't trigger it (but I also don't think my slightly older WezTerm version supports Kitty passthrough).
I doubt it's related to png vs. jpeg, but I ran some tests just now and was reminded that tmux has a hard upper limit on the size of the image data that can be transferred -- it will discard image data that is too big. Maybe they will all come through with smaller output sizes, e.g. with
Great! Could you open a separate bug for improved fzf support? Once we have a handle on the issues outside fzf, we can deal with that there.
I think it should do what you're trying to by default, without any options. |
If you select the environment variables carefully, this is not a risk. But note that a malicious user on the server could be able to see the environment variables you pass (along with anything else you do in the server-side session). As an example, some Linux distributions come pre-configured with a SendEnv/AcceptEnv list that includes LANG and LC_* variables. |
Sorry for the late reply.
I'm having a difficult time reproducing a full crash but this is the output I'm currently getting and there's a lag but subsequent runs don't have the lag. I did do an update since the issue was opened so idk if that resolved things or there was a fluke. But I suspect there was some things that got fixed (more later). I can still open a new issue for this if you'd like.
If I run the command in front of the machine, not over ssh then I get the same output as the
So I did this again. Over ssh, no issues. Image quality isn't the best but it isn't bad. Like text is readable but not crisp. SSH + tmux we get missing images again. Changing So this is why I think the upgrade may have thrown a wrench in the debugging. I decided to try another experiment btw. That screenshot I keep testing is exiftool output$ exiftool screenshot.png
ExifTool Version Number : 12.96
File Name : screenshot.png
Directory : .
File Size : 112 kB
File Modification Date/Time : 2024:08:16 16:07:56-07:00
File Access Date/Time : 2024:08:16 16:07:56-07:00
File Inode Change Date/Time : 2024:09:02 12:33:07-07:00
File Permissions : -rw-r--r--
File Type : PNG
File Type Extension : png
MIME Type : image/png
Image Width : 578
Image Height : 304
Bit Depth : 8
Color Type : RGB
Compression : Deflate/Inflate
Filter : Adaptive
Interlace : Noninterlaced
Significant Bits : 8 8 8
Image Size : 578x304
Megapixels : 0.176 So I ran It won't fit on screen until I think I understand this one. Rereading the docs I notice it says columns, not pixels. Discussing documentation I think it could help adding But this brings me to the part of my original confusion. What's the conversion of columns and rows to pixels? I notice in this particular case $ chafa -f sixel --exact-size=auto -s 50 screenshot.png
# yields size 50 image
$ chafa -f sixel --exact-size=on -s 50 screenshot.png
# yields no image
$ chafa -f sixel --exact-size=on --view-size 50 screenshot.png
# this is what I want? Do I have this right? (I don't think so: see edit) With
And I apologize I'm unraveling things haha. I'll get the [EDIT] Okay, I'm more confused about There is a possible conflict though as when starship_zle-keymap-select-wrapped:1: maximum nested function level reached; increase FUNCNEST? BUT exiting |
Concerning Wezterm + Tmux... There's no point trying to use See the list at wezterm/wezterm#986. Wezterm is simply ignoring the These codepoints are displayed as such (and you get a warning) because they are within Unicode PUA and normal fonts don't map any glyphs to them. The reason you aren't seeing the image when running tmux is most likely because tmux overwrites it in the course or displaying the diacritics i.e the image is probably actually displayed but before you see it, it's been overwritten by the diacritics for the placeholders. EDIT: As for the rest of your comment, I'm honestly not sure what exactly is being addressed but concerning image size with sixels, I'd like to remind you that tmux has a limit for sixel payloads. |
This allows WezTerm detection inside tmux, which overrides TERM_PROGRAM. Ref: #217 (GitHub).
@stevenwalton I think the latest commits to the master branch should address most of your concerns. It allows WezTerm to be detected inside tmux, and disables passthrough for tmux 3.4+, so you get native sixels instead. It's technically possible to work around the tmux sixel limit too, but that'd be a lot more complex. I'd rather addess that in a new, longer-term issue. Likewise detecting sixel capability over ssh without access to the env vars. Sound ok? |
Okay after upgrading there is a SIGNIFICANT increase in the number of successful files when using that find command (with For what pictures aren't working, this is still unclear but I think it is A minor glitch is when in So I'm more than happy to close the issue. Thanks for all the help! EDIT: In case anyone visits this issue in the future looking to do similar things here is the relevant section in my dotfiles. At time of commentfunction export_fzf_defaults() {
FZF_DEFAULT_OPTS='--ansi --preview '
# If we have chafa installed then let's display pictures
# For this to work properly we need chafa to be >= 1.14.4
# https://github.com/hpjansson/chafa/issues/217
if ( _exists chafa );
then
FZF_DEFAULT_OPTS+='"if file --mime-type {} | grep -qF image; then chafa '
FZF_DEFAULT_OPTS+='--passthrough none -f sixels --size '
# tmux can't display as large of images so we'll need to reduce them to
# 30 as this is the max (determined by testing)
if [[ $(env | grep tmux) ]];
then
FZF_DEFAULT_OPTS+='30 '
else
FZF_DEFAULT_OPTS+='${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES} '
fi
# Note the 'elif' for the bat lines
FZF_DEFAULT_OPTS+='{}; elif '
else
FZF_DEFAULT_OPTS+='"if '
fi
FZF_DEFAULT_OPTS+='file --mime-type {} | grep -aF -e directory; then '
if (_exists lsd);
then
FZF_DEFAULT_OPTS+='lsd --color always --icon always --almost-all '
FZF_DEFAULT_OPTS+='--oneline --classify --long {}; '
else
FZF_DEFAULT_OPTS+='ls --color=always -Al {}; '
fi
if (_exists strings);
then
FZF_DEFAULT_OPTS+='elif file --mime-type {} | grep -aF -e binary; then '
FZF_DEFAULT_OPTS+='strings {} | '
if ( _exists bat );
then
FZF_DEFAULT_OPTS+='bat '
else
FZF_DEFAULT_OPTS+='batcat '
fi
FZF_DEFAULT_OPTS+='--color always --language c; '
fi
# If it is a text or json file we'll read it with bat
# We could probably fizzbuzz this and just check that it isn't a bin
FZF_DEFAULT_OPTS+='elif file --mime-type {} | grep -aF -e text -e json -e '
FZF_DEFAULT_OPTS+='empty; then '
# Support batcat with older Ubuntu
if ( _exists bat );
then
FZF_DEFAULT_OPTS+='bat '
else
FZF_DEFAULT_OPTS+='batcat '
fi
FZF_DEFAULT_OPTS+='--color=always --theme=Dracula --style=numbers,grid '
FZF_DEFAULT_OPTS+='--line-range :500 {}; fi"'
export FZF_DEFAULT_OPTS="${FZF_DEFAULT_OPTS}"
}
export_fzf_defaults |
This allows WezTerm detection inside tmux, which overrides TERM_PROGRAM. Ref: #217 (GitHub).
I've been trying to get
chafa
to work well withfzf
(on wezterm) so I can remotely preview images on my servers. When sshing in I seem to be getting an issue where I require using the-f sixels
command.Here's an example when I'm just sshing and there is no
fzf
nortmux
involved (the command is similar to what I have in myfzf
configuration).(
ssh
)There's two things that seem off to me
--size
(full command beingchafa -s 120x80 20240320_073017.jpg
)This can be resolved through
-f sixels
but this is where things get weird. Outside oftmux
, things work as expected (yay, problem solved?) but once intmux
jpeg images just don't render. Let me demonstrate(I'll put most images in dropdowns with default close for easier reading of the issue)
Example with sixels enabled where we see high quality image (`ssh` + `-f sixels`)
Example within `tmux` over `ssh` (`tmux` + `ssh`)
Adding Passthrough (`tmux` + `ssh `+ `--passthrough auto`)
Now let's add our
-f sixels
flag (tmux
+ssh
+-f sixels
)`tmux` + `ssh` + `-f sixels` + `--passthrough auto`
Okay, but what about a png? (`ssh` + `tmux` + `-f sixels`)
If I try to scroll then the image disappears so I can't include the command in the screenshot :(
So I'm not quite sure what is actually going on here and what the issue is. But it appears to me that when using
tmux
andssh
jpegs do not render but pngs do.When not
ssh
ing I only have issues when usingtmux
and/orfzf
Maybe I've missed something in the docs but I tried looking and didn't see any issue related to this.
Relevant info:
Host machine:
Client machine:
MacBook Air M2
Sonoma 14.6.1
related
fzf
config lines (but this is tangential to the issue since this is all without fzf, but is the end goal)Let me know if there is more information needed or if I've missed something.
The text was updated successfully, but these errors were encountered: