我的网站内有客户产品的图片,我们不能要求客户都有能力处理图片,所以图片的大小不好控制,
在网页内 显示图片的时候,如何能设置图片长宽,如果图片实际长宽大于设定值,那就按照设置的长宽显示,如果图片的实际长宽小于设定值那么就按照图片原始的图片大小显示。我开发使用 asp.net 开发的网站。在网上查找半天没有找到合适的解决方案,请高手们指点,谢谢。另外,CSDN 的这个富文本框是免费的吗? 我看网上很少有论坛里面的富文本框使用 fckeditor 的。
在网页内 显示图片的时候,如何能设置图片长宽,如果图片实际长宽大于设定值,那就按照设置的长宽显示,如果图片的实际长宽小于设定值那么就按照图片原始的图片大小显示。我开发使用 asp.net 开发的网站。在网上查找半天没有找到合适的解决方案,请高手们指点,谢谢。另外,CSDN 的这个富文本框是免费的吗? 我看网上很少有论坛里面的富文本框使用 fckeditor 的。
判断宽高
如果超过生成一张缩略图
还有一些jquery的也蛮好用的
System.Drawing.Image myImage = System.Drawing.Image.FromFile(Request.PhysicalApplicationPath+cccc[ "cp_images"].ToString());
if(myImage.Width>myImage.Height&&myImage.Width>500)
{
Image1.Width=500;
Image1.Height=myImage.Height*500/myImage.Width;
}
else if(myImage.Width<myImage.Height&&myImage.Height>500)
{
Image1.Height=500;
Image1.Width=myImage.Width*500/myImage.Height;
}
else
{
Image1.Width=myImage.Width;
Image1.Height=myImage.Height;
}
var flag=false;
function DrawImage(ImgD,iwidth,iheight){
var image=new Image();
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;
} }
}
http://www.open-open.com/ajax/Editor.htm