Fit table-cell images to their source aspect ratio
This commit is contained in:
1 parent
87a81f16cd
commit
b41a2a9a97
2 files changed
+9
-1
No files matched your search
@@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user