用JS 获取
强行改变 一个对象模型下面 图片的大小 图片的大小让JS自动获取
public static void ResizeImage(string image, string Okey, string key, int width, int height, string newimagename) { System.Drawing.Image oImg = System.Drawing.Image.FromFile(HttpContext.Current.Server.MapPath("~/" + ConfigurationManager.AppSettings[Okey] + image)); System.Drawing.Image oThumbNail = new System.Drawing.Bitmap(width, height);//, System.Drawing.Imaging.PixelFormat.Format24bppRgb System.Drawing.Graphics oGraphic = System.Drawing.Graphics.FromImage(oThumbNail); oGraphic.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; //set smoothing mode to high quality oGraphic.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; //set the interpolation mode oGraphic.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; //set the offset mode oGraphic.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; System.Drawing.Rectangle oRectangle = new System.Drawing.Rectangle(0, 0, width, height); oGraphic.DrawImage(oImg, oRectangle); if (newimagename == "") { if (image.Substring(image.LastIndexOf(".")) != ".png") oThumbNail.Save(HttpContext.Current.Server.MapPath("~/" + ConfigurationManager.AppSettings[Okey] + image), System.Drawing.Imaging.ImageFormat.Jpeg); else oThumbNail.Save(HttpContext.Current.Server.MapPath("~/" + ConfigurationManager.AppSettings[Okey] + image), System.Drawing.Imaging.ImageFormat.Png); } else { if (newimagename.Substring(newimagename.LastIndexOf(".")) != ".png") oThumbNail.Save(HttpContext.Current.Server.MapPath("~/" + ConfigurationManager.AppSettings[Okey] + newimagename), System.Drawing.Imaging.ImageFormat.Jpeg); else oThumbNail.Save(HttpContext.Current.Server.MapPath("~/" + ConfigurationManager.AppSettings[Okey] + newimagename), System.Drawing.Imaging.ImageFormat.Png); } oImg.Dispose(); }