有谁知道ASP图片显示的问题

来源:百度知道 编辑:UC知道 时间:2024/07/02 14:57:27
我要上传几张上传的图片,大小不一定的,我要在显示的时候,要它原来图片大小的一半,我用SIZE=AUTO可以显示图片的原来的大小,但是我用SIZE=AUTO/2就不行各位高手有什么决招没有呢,其它的方法也行,前提是我不知道那个图片一定是多大的.不要跟我说width="200"/2,height="101"/2。有其它办法吗?
我想说的是,先提取宽高,再按比例缩放

你其实根本不用管你的图片有多大,你要注意的是你排版的页面,框架内可以显示多大的图片.

可以固定图片的宽或者高,这里以固定宽为例

<img src="001.jpg" onload="if(this.width>100){this.width=100;}">

图片加载的时候,为以宽100为标准,自动按例缩小

<img src="001.jpg" onload="this.width=this.width/2">

<scriptlanguage="javascript">//图片按比例缩放,可输入参数设定初始大小functionresizeimg(ImgD,iwidth,iheight) {varimage=newImage();
image.src=ImgD.src;if(image.width>0 && image.height>0){if(image.width/image.height>= iwidth/iheight){if(image.width>iwidth){
ImgD.width=iwidth;
ImgD.height=(image.height*iwidth)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}else{if(image.height>iheight){
ImgD.height=iheight;
ImgD.width=(image.width*iheight)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt