.net 后台获取服务器图片实际大小

如果你想要在后台获取图片大小,可以 
System.Drawing.Image img = System.Drawing.Image.FromFile( Server.MapPath("image/2.gif")); 
//如果是上传的文件,可以用System.Drawing.Image img = System.Drawing.Image.FromStream(this.File1.PostedFile.InputStream); 
int height = img.Height; 
int width = img.Width;

/*设置图片的宽和高*/

img.Height = bmp.Height;
img.Width = bmp.Width;

posted on 2014-10-13 16:32  D.ie  阅读(220)  评论(0编辑  收藏  举报

导航