JavaScript 取得圖片長寬與大小 How JavaScript get picture width & height & size

JavaScript 取得圖片長寬與判斷大小

 程式範例如下

$('#IMAGE').change
		(
			function()
			{
			
			    //圖片長寬取得
			    var img     = document.getElementById('M_IMAGE');
			    var width   = img.clientWidth;
			    var height  = img.clientHeight;
			    alert(width);
			    alert(height);
    
                //圖片大小取得
                var f = this.files[0]
        
				if ((f.size||f.fileSize) / 1024 > 160)
				{
					alert('上傳圖片不可大於 160 K');
					this.value	=	'';
				}
			}
		)

參考來源:

https://stackoverflow.com/questions/623172/how-to-get-image-size-height-width-using-javascript#