我想在客户端验证图像,根据预定义的标准检查尺寸。
答案 0 :(得分:0)
这可以帮助您了解如何做到这一点。
var img = new Image();
var base64Image = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJ1BMVEUAAACAgIDo6Ojq6urt7e3v7+/x8fH09PT29vb4+Pj6+vr9/f3///8nK8D7AAAAAXRSTlMAQObYZgAAAFZJREFUCB0FwcERAUEUBcCe8d1lIJSVyYZCKPIRidObi61VitENoLUTSGsPeC0lsOmSZB1K2OfQ5ZrbHLq8n9ahxP2Yjy4XS4YSh/gqcY6fEphKAAAA/p/UJlqT/uIiAAAAAElFTkSuQmCC';
img.onload = function(){
document.getElementById('imgData').innerHTML = "Widht: "+img.width+" Height:"+img.height;
};
img.src = base64Image;
<div id='imgData'></div>