mirror of
https://github.com/sxyazi/yazi.git
synced 2024-11-24 01:48:00 +03: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
@ -8,7 +8,7 @@ use tracing::{debug, warn};
|
||||
use yazi_config::PREVIEW;
|
||||
use yazi_shared::RoCell;
|
||||
|
||||
use crate::{Adapter, Image};
|
||||
use crate::{Adapter, Dimension};
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
static DEMON: RoCell<Option<UnboundedSender<Option<(PathBuf, Rect)>>>> = RoCell::new();
|
||||
@ -50,9 +50,16 @@ impl Ueberzug {
|
||||
let ImageSize { width: w, height: h } =
|
||||
tokio::task::spawn_blocking(move || imagesize::size(p)).await??;
|
||||
|
||||
let area = Image::pixel_area((w as u32, h as u32), max);
|
||||
tx.send(Some((path.to_owned(), area)))?;
|
||||
let area = Dimension::ratio()
|
||||
.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);
|
||||
Ok(area)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user