public string UploadImageResize(FileUpload fileupload, int MaxWidth, int MaxHeight, int ImgQuality, string path) { HttpContext current = HttpContext.Current; if (!Directory.Exists(current.Server.MapPath("~/" + path))) { Directory.CreateDirectory(current.Server.MapPath("~/" + path)); } string str = current.Server.MapPath("~/" + path + "/"); string result = ""; if (fileupload.HasFile) { string text = DateTime.Now.Ticks.ToString(); byte[] bytes = new ImageResizer { MaxWidth = MaxWidth, MaxHeight = MaxHeight, ImgQuality = ImgQuality, OutputFormat = ImageFormat.Jpeg }.Resize(fileupload.PostedFile); File.WriteAllBytes(str + text + ".jpg", bytes); result = path + "/" + text + ".jpg"; } return(result); }
protected void generateThumbnail(HttpPostedFile postedFile, string fileid) { string thumpath = ""; thumpath = Server.MapPath(Global.THUMBNAIL_PHOTOS); System.Drawing.Image sourceImaget = System.Drawing.Image.FromStream(postedFile.InputStream); PAB.ImageResizer.ImageResizer resizert = new PAB.ImageResizer.ImageResizer(); resizert.MaxHeight = 200; resizert.MaxWidth = 200; resizert.ImgQuality = 50; resizert.OutputFormat = PAB.ImageResizer.ImageFormat.Jpeg; byte[] bytest = resizert.Resize(postedFile); File.WriteAllBytes(thumpath + @"\" + fileid + ".jpg", bytest); }
public string UploadMutilImageResize(HttpPostedFile fileupload, int MaxWidth, int MaxHeight, int ImgQuality, string filename, string path) { HttpContext current = HttpContext.Current; if (!Directory.Exists(current.Server.MapPath("~/" + path))) { Directory.CreateDirectory(current.Server.MapPath("~/" + path)); } string str = current.Server.MapPath("~/" + path + "/"); byte[] bytes = new ImageResizer { MaxWidth = MaxWidth, MaxHeight = MaxHeight, ImgQuality = ImgQuality, OutputFormat = ImageFormat.Jpeg }.Resize(fileupload); File.WriteAllBytes(str + filename + ".jpg", bytes); return(filename + ".jpg"); }