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); }
protected void lbtnAddPhotos_Click(object sender, EventArgs e) { //showmsg("Hello"); //MessageBox1.ShowSuccess("Success, page processed.", 1000); if (FileUploadPhoto.HasFile) { HttpPostedFile postedFile = FileUploadPhoto.PostedFile; try { string fileid = SavePhotos(); generateThumbnail(postedFile, fileid); System.Drawing.Image sourceImage = System.Drawing.Image.FromStream(postedFile.InputStream); PAB.ImageResizer.ImageResizer resizer = new PAB.ImageResizer.ImageResizer(); if (sourceImage.Width > 1000) { resizer.MaxHeight = sourceImage.Height / 2; resizer.MaxWidth = sourceImage.Width / 2; } resizer.ImgQuality = 50; resizer.OutputFormat = PAB.ImageResizer.ImageFormat.Jpeg; byte[] bytes = resizer.Resize(postedFile); File.WriteAllBytes(Server.MapPath(Global.USER_PHOTOS) + @"\" + fileid + ".jpg", bytes); //FileUpload1.SaveAs(Server.MapPath(Global.USER_PHOTOS) + fileid + ".jpg"); //WallPost(fileid); uploadedPhotoliteral = ""; LiteralUploadPhoto.Text = "<img name='image' id='image' src='../../Resources/ThumbnailPhotos/" + fileid + ".jpg" + "'/>"; videofileuploaded = false; photofileuploaded = true; uploadedPhotoliteral += "<br/><br/><img name='image' id='image' src='../../Resources/ThumbnailPhotos/" + fileid + ".jpg" + "'/>"; //uploadedPhotoliteral += "<br/><br/> <a href=\"ViewPhoto.aspx?PhotoId=" + fileid + "\">photo</a> "; // LoadWall(100); photoid = fileid; } catch (Exception ex) { } } }