/// <summary> /// Create a new image. /// </summary> /// <param name="Url">URL from where the image data can be fetched through a web browser (about 512 pixels).</param> /// <param name="Thumbnail">URL from where a thumbnail of the image can be fetched through a webbrowser (about 128 pixels).</param> /// <param name="Category">Describes what the image is used for.</param> /// <param name="Type">Image type like: gif, jpeg, png, svg.</param> /// <param name="Width">Width of the full scale image.</param> /// <param name="Height">Height of the full scale image.</param> public Image(Uri Url, Uri Thumbnail, ImageCategoryType Category, ImageFileType Type, UInt32 Width, UInt32 Height) { #region Initial checks if (Url == null) throw new ArgumentNullException("Url", "The given parameter must not be null!"); #endregion this._Url = Url; this._Thumbnail = Thumbnail; this._Category = Category; this._Type = Type; this._Width = Width; this._Height = Height; }
/// <summary> /// Create a new image. /// </summary> /// <param name="Url">URL from where the image data can be fetched through a web browser (about 512 pixels).</param> /// <param name="Thumbnail">URL from where a thumbnail of the image can be fetched through a webbrowser (about 128 pixels).</param> /// <param name="Category">Describes what the image is used for.</param> /// <param name="Type">Image type like: gif, jpeg, png, svg.</param> /// <param name="Width">Width of the full scale image.</param> /// <param name="Height">Height of the full scale image.</param> public Image(Uri Url, Uri Thumbnail, ImageCategoryType Category, ImageFileType Type, UInt32 Width, UInt32 Height) { #region Initial checks if (Url == null) { throw new ArgumentNullException("Url", "The given parameter must not be null!"); } #endregion this._Url = Url; this._Thumbnail = Thumbnail; this._Category = Category; this._Type = Type; this._Width = Width; this._Height = Height; }
/// <summary> /// Builds the image dynamically based upon the store setting sizes call this before giving image source /// </summary> /// <param name="imageFile">Name of the image as in db</param> /// <param name="type">Type could be small,medium or large based on front-end requirement</param> /// <param name="aspxCommonObj"></param> public static void ImageBuilder(string imageFile, ImageType type, ImageCategoryType imgCategory, AspxCommonInfo aspxCommonObj) { try { string filename = imageFile; bool isExistImage = false; string sourceFolder = string.Empty; string imgDestintionloc = string.Empty; string imageSourceloc = string.Empty; string destinationFolder = string.Empty; IsWaterMark isWM = IsWaterMark.False; if (imgCategory == ImageCategoryType.Item) { sourceFolder = StrRootPath + @"Modules\AspxCommerce\AspxItemsManagement\uploads\" + @"" + filename + ""; imgDestintionloc = StrRootPath + @"Modules\AspxCommerce\AspxItemsManagement\uploads\"; imageSourceloc = StrRootPath + @"Modules\AspxCommerce\AspxItemsManagement\uploads\"; isWM = IsWaterMark.True; } else if (imgCategory == ImageCategoryType.Brand) { sourceFolder = StrRootPath + @"Modules\AspxCommerce\AspxBrandManagement\uploads\" + @"" + filename + ""; imgDestintionloc = StrRootPath + @"Modules\AspxCommerce\AspxBrandManagement\uploads\"; imageSourceloc = StrRootPath + @"Modules\AspxCommerce\AspxBrandManagement\uploads\"; isWM = IsWaterMark.False; } else if (imgCategory == ImageCategoryType.Category) { sourceFolder = StrRootPath + @"Modules\AspxCommerce\AspxCategoryManagement\uploads\" + @"" + filename + ""; imgDestintionloc = StrRootPath + @"Modules\AspxCommerce\AspxCategoryManagement\uploads\"; imageSourceloc = StrRootPath + @"Modules\AspxCommerce\AspxCategoryManagement\uploads\"; isWM = IsWaterMark.False; } ResizeSettings resizeSetings = new ResizeSettings(); resizeSetings.Format = "jpg"; resizeSetings.Mode = FitMode.Carve; resizeSetings.Scale = ScaleMode.Both; resizeSetings.Quality = 75; switch (type) { case ImageType.Large: { string imgFolder = imageSourceloc + @"" + type + ""; destinationFolder = imgDestintionloc + @"" + type + @"\" + filename + ""; isExistImage = CheckIfImageExists(filename, imgFolder); if (!(isExistImage)) { ImageSettings imgStng = new ImageSettings(aspxCommonObj); if (Convert.ToBoolean(imgStng.ResizeImagesProportionally) == true) { resizeSetings.Width = imgStng.ItemLargeThumbNailWidth; } else { resizeSetings.Width = imgStng.ItemLargeThumbNailWidth; resizeSetings.Height = imgStng.ItemLargeThumbNailHeight; } copyOriginalImageToRespectives(resizeSetings, sourceFolder, destinationFolder, aspxCommonObj, isWM); } break; } case ImageType.Medium: { string imgFolder = imageSourceloc + @"" + type + ""; destinationFolder = imgDestintionloc + @"" + type + @"\" + filename + ""; isExistImage = CheckIfImageExists(filename, imgFolder); if (!(isExistImage)) { ImageSettings imgStng = new ImageSettings(aspxCommonObj); if (Convert.ToBoolean(imgStng.ResizeImagesProportionally) == true) { resizeSetings.Width = imgStng.ItemMediumThumbNailWidth; } else { resizeSetings.Width = imgStng.ItemMediumThumbNailWidth; resizeSetings.Height = imgStng.ItemMediumThumbNailWidth; } copyOriginalImageToRespectives(resizeSetings, sourceFolder, destinationFolder, aspxCommonObj, isWM); } break; } case ImageType.Small: { string imgFolder = imageSourceloc + @"" + type + ""; destinationFolder = imgDestintionloc + @"" + type + @"\" + filename + ""; isExistImage = CheckIfImageExists(filename, imgFolder); if (!(isExistImage)) { ImageSettings imgStng = new ImageSettings(aspxCommonObj); if (Convert.ToBoolean(imgStng.ResizeImagesProportionally) == true) { resizeSetings.Width = imgStng.ItemSmallThumbNailHeight; } else { resizeSetings.Width = imgStng.ItemSmallThumbNailHeight; resizeSetings.Height = imgStng.ItemSmallThumbNailHeight; } copyOriginalImageToRespectives(resizeSetings, sourceFolder, destinationFolder, aspxCommonObj, isWM); } break; } } } catch { } }
/// <summary> /// Builds the image dynamically based upon the store setting sizes call this before giving image source /// </summary> /// <param name="imageFile">Name of the image as in db</param> /// <param name="type">Type could be small,medium or large based on front-end requirement</param> /// <param name="aspxCommonObj"></param> public static void ImageBuilder(string imageFile, ImageType type,ImageCategoryType imgCategory,AspxCommonInfo aspxCommonObj) { try { string filename = imageFile; bool isExistImage = false; string sourceFolder=string.Empty; string imgDestintionloc = string.Empty; string imageSourceloc = string.Empty; string destinationFolder = string.Empty; IsWaterMark isWM = IsWaterMark.False; if (imgCategory == ImageCategoryType.Item) { sourceFolder = StrRootPath + @"Modules\AspxCommerce\AspxItemsManagement\uploads\" + @"" + filename + ""; imgDestintionloc = StrRootPath + @"Modules\AspxCommerce\AspxItemsManagement\uploads\"; imageSourceloc = StrRootPath + @"Modules\AspxCommerce\AspxItemsManagement\uploads\"; isWM = IsWaterMark.True; } else if (imgCategory == ImageCategoryType.Brand) { sourceFolder = StrRootPath + @"Modules\AspxCommerce\AspxBrandManagement\uploads\" + @"" + filename + ""; imgDestintionloc = StrRootPath + @"Modules\AspxCommerce\AspxBrandManagement\uploads\"; imageSourceloc = StrRootPath + @"Modules\AspxCommerce\AspxBrandManagement\uploads\"; isWM = IsWaterMark.False; } else if (imgCategory == ImageCategoryType.Category) { sourceFolder = StrRootPath + @"Modules\AspxCommerce\AspxCategoryManagement\uploads\" + @"" + filename + ""; imgDestintionloc = StrRootPath + @"Modules\AspxCommerce\AspxCategoryManagement\uploads\"; imageSourceloc = StrRootPath + @"Modules\AspxCommerce\AspxCategoryManagement\uploads\"; isWM = IsWaterMark.False; } ResizeSettings resizeSetings = new ResizeSettings(); resizeSetings.Format = "jpg"; resizeSetings.Mode = FitMode.Carve; resizeSetings.Scale = ScaleMode.Both; resizeSetings.Quality = 75; switch (type) { case ImageType.Large: { string imgFolder = imageSourceloc + @"" + type + ""; destinationFolder = imgDestintionloc+ @"" + type + @"\" + filename + ""; isExistImage = CheckIfImageExists(filename, imgFolder); if (!(isExistImage)) { ImageSettings imgStng = new ImageSettings(aspxCommonObj); if (Convert.ToBoolean(imgStng.ResizeImagesProportionally) == true) { resizeSetings.Width = imgStng.ItemLargeThumbNailWidth; } else { resizeSetings.Width = imgStng.ItemLargeThumbNailWidth; resizeSetings.Height = imgStng.ItemLargeThumbNailHeight; } copyOriginalImageToRespectives(resizeSetings, sourceFolder, destinationFolder, aspxCommonObj, isWM); } break; } case ImageType.Medium: { string imgFolder = imageSourceloc + @"" + type + ""; destinationFolder = imgDestintionloc + @"" + type + @"\" + filename + ""; isExistImage = CheckIfImageExists(filename, imgFolder); if (!(isExistImage)) { ImageSettings imgStng = new ImageSettings(aspxCommonObj); if (Convert.ToBoolean(imgStng.ResizeImagesProportionally) == true) { resizeSetings.Width = imgStng.ItemMediumThumbNailWidth; } else { resizeSetings.Width = imgStng.ItemMediumThumbNailWidth; resizeSetings.Height = imgStng.ItemMediumThumbNailWidth; } copyOriginalImageToRespectives(resizeSetings, sourceFolder, destinationFolder, aspxCommonObj, isWM); } break; } case ImageType.Small: { string imgFolder = imageSourceloc + @"" + type + ""; destinationFolder = imgDestintionloc + @"" + type + @"\" + filename + ""; isExistImage = CheckIfImageExists(filename, imgFolder); if (!(isExistImage)) { ImageSettings imgStng = new ImageSettings(aspxCommonObj); if (Convert.ToBoolean(imgStng.ResizeImagesProportionally) == true) { resizeSetings.Width = imgStng.ItemSmallThumbNailHeight; } else { resizeSetings.Width = imgStng.ItemSmallThumbNailHeight; resizeSetings.Height = imgStng.ItemSmallThumbNailHeight; } copyOriginalImageToRespectives(resizeSetings, sourceFolder, destinationFolder, aspxCommonObj, isWM); } break; } } } catch { } }