Search code examples
c#javascriptasp.netimageurl

Is it possible to get image size by Image url using Javascript


There is an image url, this image's size must be reduced proportionally by the minimum width and height so that it can be shown in a template.

The aforementioned template and its content will be generated into the html using javascript. So i have to find a way to get the image size from an image url using javascript so that the size of the image can be reduced proportionally, is it possible to do this?

I am working on asp.net and c#.


Solution

  • If I understand correctly you want to load an image and scale it down proportionally to fit a certain space on your screen?

    You don't need to calculate anything in that case but rather just set the CSS width/height to the maximum space you want to fit the image upon load. The browser will itself scale the image proportionally down to fit the space