Proportional image resize

前端 未结 6 1004
南笙
南笙 2020-12-07 14:51

I\'m having a little bit of a problem scaling my images to a properly predefined size. I was wondering - since it is purely mathematics, if there\'s some sort of common logi

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-07 15:25

    Dark Shikari has it. Your solution as stated in the question fails because you aren't first establishing which dimenson's size-to-maxsize ratio is greater and then reducing both dimensions by that greater ratio.

    Your current solution's use of a serial, conditional analysis of one potential dimensional violation and then the other won't work.

    Note also that if you want to upscale images, your current solution won't fly, and Dark Shikari's again will.

提交回复
热议问题