mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
fix(02-01): add max(1.0) safety clamp to aspect ratio calculation
This commit is contained in:
parent
3c9e936653
commit
fc71331305
1 changed files with 4 additions and 1 deletions
|
|
@ -105,7 +105,10 @@ impl Image {
|
|||
// DynamicImage::resize() behavior.
|
||||
let (w, h) = {
|
||||
let ratio = (w as f64 / img.width() as f64).min(h as f64 / img.height() as f64);
|
||||
((img.width() as f64 * ratio).round() as u32, (img.height() as f64 * ratio).round() as u32)
|
||||
(
|
||||
(img.width() as f64 * ratio).round().max(1.0) as u32,
|
||||
(img.height() as f64 * ratio).round().max(1.0) as u32,
|
||||
)
|
||||
};
|
||||
|
||||
let img = match img.pixel_type() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue