0

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#.

Ashwin Krishnamurthy
  • 3,750
  • 3
  • 27
  • 49
Sarawut Positwinyu
  • 4,974
  • 15
  • 54
  • 80

2 Answers2

1

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

Tigraine
  • 23,358
  • 11
  • 65
  • 110
0

Not directly but you can use a trick: The URL must be generated somewhere; probably on the server.

What you can do is generate this url: http://domain/path/image.png?size=320x200

The server will ignore the parameter size when the browser downloads the image but you can examine this part of the URL in your JavaScript.

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820