页网中控台绘图片放缩编码,一般状况下,是难以保证这一点的,由于小图从数据信息库启用出去的情况下小,而当启用的照片是超清的数码科技照时,你才了解那有双头痛,彻底把Tabel挤得不象人样,全挤破了,不好看得害怕见人啊,要把照片操纵在一定的规格型号里放缩,我觉得到的是用JavaScript,总算写成来啦,检测了N多回才取得成功的,可以看编码:
网页页面前边加(留意JavaScript是区别尺寸写的,我非常讨厌就他这一点,大家无需留意了,我早已写好检测完后才传出来共享资源的,立即拷贝一点难题也没有)
script language= JavaScript
!--
//照片按占比放缩
var flag=false;
function DrawImage(ImgD){
var image=new Image();
var iwidth = 480; //界定容许照片总宽
var iheight = 530; //界定容许照片高宽比
image.src=ImgD.src;
if(image.width 0 image.height 0){
flag=true;
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=image.width+ +image.height;
}
}
}
//启用:
//--
/script
在body里 显示信息照片时
img src= 照片启用相对路径.jpg border=0
OK,就是这样拿下了,那无论是小图還是大图图片,也只有在480X530里游动啦。
感言:有时候候觉得写程序便是那麼开心,仿佛一切尽在撑握当中,由于又学得了物品。谁有更简易的,请共享资源下技术性吧!
文中源于: 友谊同盟--- ASP技术性同盟区 转截请保存连接,感谢。