javascript/jquery获取图片的原始大小
实际生产过程中,我们往往有需要获得一个被压缩的图片的真实原始大小。此时我们可以用下面这个代码来实现:
[js]
// Get on screen image
var screenImage = $("#image");
// Create new offscreen image to test
var theImage = new Image();
theImage.src = screenImage.attr("src");
// Get accurate measurements from that.
var imageWidth = theImage.width;
var imageHeight = theImage.height;
[/js]