冰风飒的博客

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]

posted on 2013-05-07 23:24  冰风飒  阅读(...)  评论(...编辑  收藏

My Links

Blog Stats