mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
fix: ueberzug image adapter should respect the user's max_width and max_height settings (#1200)
This commit is contained in:
parent
f1cf136df4
commit
9a5b75662a
1 changed files with 10 additions and 3 deletions
|
|
@ -8,7 +8,7 @@ use tracing::{debug, warn};
|
||||||
use yazi_config::PREVIEW;
|
use yazi_config::PREVIEW;
|
||||||
use yazi_shared::RoCell;
|
use yazi_shared::RoCell;
|
||||||
|
|
||||||
use crate::{Adapter, Image};
|
use crate::{Adapter, Dimension};
|
||||||
|
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
static DEMON: RoCell<Option<UnboundedSender<Option<(PathBuf, Rect)>>>> = RoCell::new();
|
static DEMON: RoCell<Option<UnboundedSender<Option<(PathBuf, Rect)>>>> = RoCell::new();
|
||||||
|
|
@ -50,9 +50,16 @@ impl Ueberzug {
|
||||||
let ImageSize { width: w, height: h } =
|
let ImageSize { width: w, height: h } =
|
||||||
tokio::task::spawn_blocking(move || imagesize::size(p)).await??;
|
tokio::task::spawn_blocking(move || imagesize::size(p)).await??;
|
||||||
|
|
||||||
let area = Image::pixel_area((w as u32, h as u32), max);
|
let area = Dimension::ratio()
|
||||||
tx.send(Some((path.to_owned(), area)))?;
|
.map(|(r1, r2)| Rect {
|
||||||
|
x: max.x,
|
||||||
|
y: max.y,
|
||||||
|
width: max.width.min((w.min(PREVIEW.max_width as _) as f64 / r1).ceil() as _),
|
||||||
|
height: max.height.min((h.min(PREVIEW.max_height as _) as f64 / r2).ceil() as _),
|
||||||
|
})
|
||||||
|
.unwrap_or(max);
|
||||||
|
|
||||||
|
tx.send(Some((path.to_owned(), area)))?;
|
||||||
Adapter::shown_store(area);
|
Adapter::shown_store(area);
|
||||||
Ok(area)
|
Ok(area)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue