开发者

How to calculate minimum image scale?

I need to setup a jQuery UI slider as 开发者_开发知识库an image scaler, yet I need to make sure that it is restricted on the low end to meet minimum size requirements.

Given that I know the following:

  • existing image dimensions
  • minimum width and height
  • all scales are to be proportional

... how do I calculate the minimum scale (as in a percentage) so that scale of the image meets the minimum width and height requirements?

Let me know if that wasn't clear, and I'll try to clarify.


var minWidth = 100,
   minHeight = 100,
    curWidth = 600,
   curHeight = 800,
        minW = minWidth / curWidth,
        minH = minHeight / curHeight 

    minScale = Math.max(minW, minH); // .1666666666
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜