求高人分析下面的两个js
没什么好说的,主要功能都是实现改变图片大小
function DrawImage(ImgD){
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
flag=true;
if(image.width/image.height>= 164/112){
if(image.width>164){
ImgD.width=164;
ImgD.height=(image.height*164)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"x"+image.height;
} else{
if(image.height>112){
ImgD.height=112;
ImgD.width=(image.width*112)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"x"+image.height;
}
}
}
function imgReSize(obj, width, height){
if(obj.width <= width && obj.height <= height) return false;
if(obj.width*height > width*obj.height)
height = obj.height * width / obj.width;
else
width = obj.width * height / obj.height;
obj.width = width;
obj.height = height;
}