User Tools

Site Tools


rtfm:proportional-scale

Proportional scaling of rectangular objects

Calculation proof for scaling images, with a quadratic destination image and different sized source images.

Thesis

  • destination image size: $dest_width = 360 = $new_width, $dest_height = 360 (ie. quadratic), scaling is always done with the width
  • source image size: $source_width / $source_height = $source_aspect_ratio
  • calculation: $new_width / $source_aspect_ratio = $new_height

Notes

  • eg. width: 360, height = 360 (ball.svg), but auto.svg is more like 600 width, 150 height ⇒ 600 / 150 = 4 = $source_aspect_ratio (= seitenverhältnis)
    • ⇒ auto.svg would be scaled to: 360 width, $new_width / $source_aspect_ratio
      • eg. width 400, height 150, ie. 400 / 150 = 2.667
      • ⇒ (new_width = 360) / ($source_aspect_ratio = 2.667) ⇒
  • eg. width 200, height 400, ie. 200 / 400 = 0.5
  • ⇒ (new_width = 360) / ($source_aspect_ratio = 0.5) = 720 ⇒ new_height
rtfm/proportional-scale.txt · Last modified: 2022/03/04 03:26 by fwolf