sxyazi / yazi

💥 Blazing fast terminal file manager written in Rust, based on async I/O.
https://yazi-rs.github.io
MIT License
15.5k stars 348 forks source link

Kitty image previews are not scaled #479

Closed dmtrKovalenko closed 8 months ago

dmtrKovalenko commented 9 months ago

What system are you running Yazi on?

macOS

What terminal are you running Yazi in?

kitty 0.31.0

Yazi version

yazi 0.1.5

Did you try the latest main branch to see if the problem has already been fixed?

Tried, but the problem is still present

Describe the bug

Terminal images previews in kitty does not scale and are not usable

image

Expected Behavior

This is how fzf with the jcorrect preview working

  EXTERNAL_COLUMNS=$COLUMNS \
  fzf $argv \
  --preview='kitten icat --clear --transfer-mode=memory --scale-up --place="$COLUMNS"x"$LINES"@(math $EXTERNAL_COLUMNS-$COLUMNS)x0 --align center --stdin=no {} > /dev/tty' \
  --preview-window "right,50%,border-left"
image

To Reproduce

Open any folder containing images using yazi in kitty

Configuration

This is reproducible on totally default configuration

Anything else?

I assume that there might be a missing --scale-up argument when getting a preview from the kitty. I can try to check the code and see if I can fix this issue once will get a green light from maintainers.

sxyazi commented 9 months ago

Hi, you need to tune the max_width and max_height up as what you want - which will fit your terminal automatically, that's necessary for pre-caching images

github-actions[bot] commented 9 months ago

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

dmtrKovalenko commented 9 months ago

Thank you, @sxyazi for a quick answer, I am sorry for somehow missing this. I did what you said and set both of them to 4000. I also set image_alloc to 0 and image_bound to [0,0] (all unlimited) and still seeing this

image

It became bigger but it is not taking up full pane. I think the whole idea that it not tries to scale the image up. While it probably should, if the image itself is small I would like to be able to still see it even if some artifacts are visible

sxyazi commented 9 months ago

Did you do a yazi --clear-cache after setting max_width and max_height inside [preview] in your ~/.config/yazi/yazi.toml?

dmtrKovalenko commented 9 months ago

Yes exactly, the pretty big images display perfectly here is a 4k:

image
sxyazi commented 9 months ago

Oh, sorry, I seem to have misunderstood your intention.

Are you looking to enlarge an image that is initially smaller than your terminal window and to fill in it, rather than having an image larger than the terminal window to downscale to the terminal size?

If so currently, this is only can be implemented by the custom previewer - I'm not sure if it makes sense since enlarging a small image usually results in blurriness. However, I'm willing to discuss it and explore any possible way to impl it. Let me know your thoughts.

github-actions[bot] commented 8 months ago

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

Reledia commented 8 months ago

I'm sorry to come back to a closed issue, but I feel this is a feature that could be interesting in some cases. I'm not well versed in Rust, but I looked at the Image implementation, especially at the downscale method: to me it seems like it could already work as a upscale method too if a (to add) flag can be passed to skip the fast path check and the check before the resize.

Pseudo-code (idk if its correct Rust):

// Fast path.
if img.width() <= w && img.height() <= h && orientation <= 1 && !upscale {
    return Ok(img);
}

tokio::task::spawn_blocking(move || {
    if (img.width() > w || img.height() > h) || upscale  {
        img = img.resize(w, h, Self::filter())
    }
    Ok(Self::rotate(img, orientation))
})
github-actions[bot] commented 7 months ago

I'm going to lock this issue because it has been closed for 30 days. ⏳ This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.