function resizeImage(image, max) {
if (Math.max(image.width, image.height) > max) {
if (image.width > image.height) image.width = max;
else image.height = max;
}
return true;
}
<img οnlοad="var max=64;if(Math.max(this.width,this.height)>max){if(this.width>this.height)this.width=max;else this.height=max;}" src="/test.jpg" />
或者
<img οnlοad="return resizeImage(this,64)" src="/test.jpg" />