Image resize & aspect ratio
Resize an image to a target width without stretching.
How this works
Target height = original height × target width/original width; integer pixels are rounded.
Example
Using the example inputs, rounded target height is 450 px.
- Original pixel width
- 1920 px
- Original pixel height
- 1080 px
- Target pixel width
- 800 px
- Rounded target height
- 450 px
Scope and assumptions
Does not edit the image. Very small sizes may need cropping or a one-pixel adjustment.
OpenStax mathematics reference