asp.net生成缩略图,容量跟原图差不多jpg的,怎么缩小 用System.Drawing.Image生成缩略图,一个70Kb的800*600jpg图片生成后是130*130jpg的容量还有45这么大,我生成缩略图就是想让容量下加载快些,结果小这么点,我觉得这么小的jpg图片应该在10Kb左右差不多了……怎么缩小缩略图的容量呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 放 div里,控制div的高度宽度 等比例缩放图片<script language="JavaScript">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://topic.csdn.net/u/20100525/15/7b9f9fe3-e862-48b5-86e2-3b72a9525690.html /// <summary> /// 修改指定图片的分辨率 /// </summary> /// <param name="fileFoldUrl">文件夹url</param> /// <param name="fileName">文件名</param> /// <param name="filePath">文件路径,带文件名</param> /// <param name="_width">分辨率的宽</param> /// <param name="_height">分辨率的高</param> public void update_picture(string fileFoldUrl, string fileName, string filePath, int _width, int _height) { byte[] zp = this.load_pictMemory(filePath); MemoryStream ms = new MemoryStream(zp); System.Drawing.Image img = System.Drawing.Image.FromStream(ms); Bitmap btp = new Bitmap(img, _width, _height); DirectoryInfo dti = new DirectoryInfo(fileFoldUrl); FileInfo[] fis = dti.GetFiles(); string fileUrl = fileFoldUrl + fileName; btp.Save(fileUrl); } 本来我是直接放img里控制宽高,但这样不好,图片容量大了加载慢,别人要是网速慢点都很慢才显示出来,所以生成个缩略图,在首页显示,具体进去也能看大图! 求能人帮翻译一段VBA代码 关于gridview删除当前行事件 Eddie005(♂) №.零零伍 (♂) 请进 public enum action这样表示什么意思? 怎样在客户端代码中关闭浏览器窗口而不弹出提示 文件夹移动或删除会另Session丢失呀,怎么办呢?请高手指点! 我怎样判断页面中是否存在一个ID值为"aaa"的控件? 求教多数据库,多表联合查询 看来这里没有所谓的高手呀 大家帮我看看哪儿出错了? 页面跳转网址 大哥大姐们 请教mysql语句 急!
<script language="JavaScript">
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://topic.csdn.net/u/20100525/15/7b9f9fe3-e862-48b5-86e2-3b72a9525690.html
/// 修改指定图片的分辨率
/// </summary>
/// <param name="fileFoldUrl">文件夹url</param>
/// <param name="fileName">文件名</param>
/// <param name="filePath">文件路径,带文件名</param>
/// <param name="_width">分辨率的宽</param>
/// <param name="_height">分辨率的高</param>
public void update_picture(string fileFoldUrl, string fileName, string filePath, int _width, int _height)
{
byte[] zp = this.load_pictMemory(filePath);
MemoryStream ms = new MemoryStream(zp);
System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
Bitmap btp = new Bitmap(img, _width, _height);
DirectoryInfo dti = new DirectoryInfo(fileFoldUrl);
FileInfo[] fis = dti.GetFiles();
string fileUrl = fileFoldUrl + fileName;
btp.Save(fileUrl);
}