Fit table-cell images to their source aspect ratio

This commit is contained in:
gloamxun committed 2026-10-20 02:32:42 +08:00
1 parent 87a81f16cd
commit b41a2a9a97
2 files changed
+9 -1

No files matched your search

+8
View File
@@ -557,6 +557,14 @@ fn layout_table(
&& let Some(image) = rule.image.as_mut()
{
*image = source_dir.join(&*image).to_string_lossy().into_owned();
if let Ok((width, height)) = image::image_dimensions(&*image)
&& width > 0
{
rule.height = common::Scaled(
(f64::from(rule.width.0) * f64::from(height) / f64::from(width))
.round() as i32,
);
}
}
}
}