Skip to content

Commit

Permalink
fix: Contain not preserving aspect ratio of tall images
Browse files Browse the repository at this point in the history
When both width and height is set to `Contain`, the scaling uses the
wrong direct proportional scaling formula for tall images. This is due
to `aspect` being `width / height`:
By dividing (original), the formula expands to `scaled_width /
scaled_height : height / width` which inversely scaled the width of tall
images. By multiplying instead, the formula correctly expands to
`scaled_width / scaled_height : width / height` which preserves aspect
ratio when scaling.
  • Loading branch information
saltkid committed Jan 5, 2025
1 parent 8e9cf91 commit 705a546
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion wezterm-gui/src/termwindow/background.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ impl crate::TermWindow {
}
} else {
// Height is the longest side
let target_width = pixel_height / aspect;
let target_width = pixel_height * aspect;
if target_width > pixel_width {
(
pixel_width,
Expand Down

0 comments on commit 705a546

Please sign in to comment.