private void setResizedLogoURL(int docID) { bool isResizeRequired = false; DocumentDA objDocDA = new DocumentDA(); string rtnFilePath = objDocDA.GetDocumentPath(docID); if (rtnFilePath != "") { if (File.Exists(Constant.DocRepoClient + rtnFilePath)) { rtnFilePath = Constant.DocRepoClient + rtnFilePath; isResizeRequired = true; } else rtnFilePath = Constant.DocRepRoot + "NoDocs.png"; } else rtnFilePath = Constant.DocRepRoot + "NoDocs.png"; if (isResizeRequired) { List<DocumentBE> objDoc = objDocDA.GetDocumentDA(docID); if (objDoc.Count > 0) { if (!objDoc[0].isResized) { ImageUtility objImgUtil = new ImageUtility(); System.Drawing.Image original = System.Drawing.Image.FromFile(rtnFilePath); System.Drawing.Image resized = objImgUtil.ResizeImage(original, (objDoc[0].Category.ToUpper() == "LOGO" ? Common.Constant.LogoSize : Common.Constant.BannerSize)); string SavedFileName = ""; switch ((Path.GetExtension(objDoc[0].SavedFileName).Substring(1)).ToUpper()) { case "PNG": SavedFileName = docID.ToString() + "_rs.png"; resized.Save(Constant.DocRepoClient + Session["ClientID"].ToString() + "\\Logo\\" + SavedFileName, System.Drawing.Imaging.ImageFormat.Png); break; case "JPG": SavedFileName = docID.ToString() + "_rs.jpg"; resized.Save(Constant.DocRepoClient + Session["ClientID"].ToString() + "\\Logo\\" + SavedFileName, System.Drawing.Imaging.ImageFormat.Jpeg); break; case "GIF": SavedFileName = docID.ToString() + "_rs.gif"; resized.Save(Constant.DocRepoClient + Session["ClientID"].ToString() + "\\Logo\\" + SavedFileName, System.Drawing.Imaging.ImageFormat.Gif); break; } objDocDA.SaveDocumentDA(docID, "isResized", "1"); objDocDA.SaveDocumentDA(docID, "SavedFileName", "'" + SavedFileName + "'"); } } } }
private string getComponentSrc(string p1, string p2) { ImageUtility objImageUtility = new ImageUtility(); if (!File.Exists(Server.MapPath(p2))) { System.Drawing.Image original = System.Drawing.Image.FromFile(Server.MapPath(p1)); System.Drawing.Image resized = objImageUtility.ResizeImage(original, new Size(60, 60)); resized.Save(Server.MapPath(p2), System.Drawing.Imaging.ImageFormat.Png); } return p2; }
public void ProcessRequest(HttpContext context) { int docID = 0; bool isResizeRequired = false; DocumentDA objDocDA = new DocumentDA(); if (context.Request["ID"] != null) docID = Convert.ToInt32(context.Request["ID"]); string rtnFilePath = objDocDA.GetDocumentPath(docID); if (rtnFilePath != "") { if (File.Exists(Constant.DocRepoClient + rtnFilePath)) { rtnFilePath = Constant.DocRepoClient + rtnFilePath; isResizeRequired = true; } else rtnFilePath = Constant.DocRepRoot + "NoDocs.png"; } else rtnFilePath = Constant.DocRepRoot + "NoDocs.png"; context.Response.ContentType = "image/jpeg"; if (isResizeRequired) { List<DocumentBE> objDoc = objDocDA.GetDocumentDA(docID); if (objDoc.Count > 0) { if (!objDoc[0].isResized) { ImageUtility objImgUtil = new ImageUtility(); System.Drawing.Image original = System.Drawing.Image.FromFile(rtnFilePath); System.Drawing.Image resized = objImgUtil.ResizeImage(original, Common.Constant.LogoSize); switch ((Path.GetExtension(objDoc[0].SavedFileName).Substring(1)).ToUpper()) { case "PNG": resized.Save(rtnFilePath, System.Drawing.Imaging.ImageFormat.Png); break; case "JPG": resized.Save(rtnFilePath, System.Drawing.Imaging.ImageFormat.Jpeg); break; case "GIF": resized.Save(rtnFilePath, System.Drawing.Imaging.ImageFormat.Gif); break; } objDocDA.SaveDocumentDA(docID, "isResized", "1"); } } } context.Response.WriteFile(rtnFilePath); //ImageUtility objImageUtility = new ImageUtility(); //if (!File.Exists(Server.MapPath(p2))) //{ // System.Drawing.Image original = System.Drawing.Image.FromFile(Server.MapPath(p1)); // System.Drawing.Image resized = objImageUtility.ResizeImage(original, new Size(60, 60)); // resized.Save(Server.MapPath(p2), System.Drawing.Imaging.ImageFormat.Png); //} //return p2; }
private void getAudBackGround() { DirectoryInfo objDir = new DirectoryInfo(System.Web.HttpContext.Current.Server.MapPath("~/") + "Images\\backgrounds"); FileInfo[] files = null; files = objDir.GetFiles("1*.png"); int idx = 10; foreach (FileInfo ff in files) { ImageUtility objImageUtility = new ImageUtility(); System.Drawing.Image original = System.Drawing.Image.FromFile(Server.MapPath("~/images/backgrounds/" + ff.Name)); System.Drawing.Image resized = objImageUtility.ResizeImage(original, new Size(180, 120)); resized.Save(Server.MapPath("~/images/backgrounds/audibg" + idx.ToString() + ".png"), System.Drawing.Imaging.ImageFormat.Png); System.Drawing.Image resized1 = objImageUtility.ResizeImage(original, new Size(720, 480)); resized1.Save(Server.MapPath("~/images/backgrounds/pre_audibg" + idx.ToString() + ".png"), System.Drawing.Imaging.ImageFormat.Png); idx++; } rpAudBGCarousel.DataSource = objDir.GetFiles("audibg*.png"); rpAudBGCarousel.DataBind(); }