How to resize images proportionally / keeping the aspect ratio?

前端 未结 18 1938
野趣味
野趣味 2020-11-22 13:58

I have images that will be quite big in dimension and I want to shrink them down with jQuery while keeping the proportions constrained, i.e. the same aspect ratio.

C

18条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-22 14:15

    2 Steps:

    Step 1) calculate the ratio of the original width / original height of Image.

    Step 2) multiply the original_width/original_height ratio by the new desired height to get the new width corresponding to the new height.

提交回复
热议问题