Method and source check
Last checked:
Automated source and implementation review, including worked examples and documented numerical limits. This review does not provide professional advice or specialist approval.
Method
Reduce width:height to a simple ratio. If a positive new width or height is entered, scale the other dimension in proportion and round it to a whole pixel.
ratio = width:height reduced by gcd(width,height)
new height = round(new width Γ height/width)
Variables and units
- width,height
- positive original dimensions
- new width/new height
- optional positive target dimension
Worked example
For 1920Γ1080, ratio is 16:9; target width 1280 gives target height 720.
Limitations
Decimal ratio is rounded to three places; computed target dimension is rounded to the nearest whole pixel.
- Whole-pixel rounding can slightly change the exact ratio.
- Only one target dimension is used; if both are entered, width takes precedence under current behavior.
- 16:9 is preserved exactly by scaling 1920Γ1080 to 1280Γ720.
- For 3Γ2 at target width 5, rounded height 3 makes the displayed 5Γ3 an approximation.
- For 1920Γ1080, target width 1280 or target height 720 both display the complete scaled pair 1280Γ720.