0

I want to compare image before uploading to be of x by y pixels within file upload control in asp.net How can I get image size in File Uploader in pixels using javascript?

Rupesh
  • 17
  • 1
  • 6
  • 1
    Possible dublicate http://stackoverflow.com/questions/623172/how-to-get-image-size-height-width-using-javascript – dotoree Mar 03 '12 at 10:56

2 Answers2

0

One way to get the image sizes in javascript is to do the following:

var img = document.getElementById('yourimageId'); 

var width = img.clientWidth;
var height = img.clientHeight;

Also have a look at the following answer to a similar previous question:

Community
  • 1
  • 1
skub
  • 2,266
  • 23
  • 33
0

in firefox ,you can get the file's path by this method:

https://developer.mozilla.org/en/DOM/File.getAsDataURL

or latest version :

window.URL.createObjectURL(file);

for webkit window.webkitURL.createObjectURL() see https://developer.mozilla.org/en/Document_Object_Model_(DOM)/window.URL.createObjectURL

and set it to a img tag and get the size.
for ie, you shoule set a filter to the elem

progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=image)

and set the url to this filter then you can get the img's size good luck

Torrent Lee
  • 845
  • 6
  • 9