예제 #1
0
        public void AddImagesForStoreSettings(string storeSettingImageFolder, string fileName, string largeImageFolder, string mediumImageFolder, string smallImageFolder, AspxCommonInfo aspxCommonObj)
        {
            //Copy resized noitemImage and storelogo Image to the respective folders
            ResizeSettings resizeSetings = new ResizeSettings();

            resizeSetings.Format  = "jpg";
            resizeSetings.Mode    = FitMode.Carve;
            resizeSetings.Scale   = ScaleMode.Both;
            resizeSetings.Quality = 75;
            ImageSettings  imgStng              = new ImageSettings(aspxCommonObj);
            ResizeSettings resizeSettingsLarge  = new ResizeSettings(resizeSetings);
            ResizeSettings resizeSettingsMedium = new ResizeSettings(resizeSetings);
            ResizeSettings resizeSettingsSmall  = new ResizeSettings(resizeSetings);

            if (Convert.ToBoolean(imgStng.ResizeImagesProportionally) == true)
            {
                resizeSettingsLarge.Width  = imgStng.ItemLargeThumbNailWidth;
                resizeSettingsMedium.Width = imgStng.ItemMediumThumbNailWidth;
                resizeSettingsSmall.Width  = imgStng.ItemSmallThumbNailWidth;
            }
            else
            {
                resizeSettingsLarge.Width   = imgStng.ItemLargeThumbNailWidth;
                resizeSettingsLarge.Height  = imgStng.ItemLargeThumbNailHeight;
                resizeSettingsMedium.Width  = imgStng.ItemMediumThumbNailWidth;
                resizeSettingsMedium.Height = imgStng.ItemMediumThumbNailHeight;
                resizeSettingsSmall.Width   = imgStng.ItemSmallThumbNailWidth;
                resizeSettingsSmall.Height  = imgStng.ItemSmallThumbNailHeight;
            }
            copyOriginalImageToRespectives(resizeSettingsSmall, Path.Combine(storeSettingImageFolder, fileName), Path.Combine(smallImageFolder, fileName), aspxCommonObj, IsWaterMark.False);
            copyOriginalImageToRespectives(resizeSettingsMedium, Path.Combine(storeSettingImageFolder, fileName), Path.Combine(mediumImageFolder, fileName), aspxCommonObj, IsWaterMark.False);
            copyOriginalImageToRespectives(resizeSettingsLarge, Path.Combine(storeSettingImageFolder, fileName), Path.Combine(largeImageFolder, fileName), aspxCommonObj, IsWaterMark.False);
        }
        public static void ImageBuilder(string imageFile, ImageType type, bool IsInTempFolder,AspxCommonInfo aspxCommonObj)
        {

            try
            {
                bool disposeSource = true;
                bool addFileExtensions = true;
                string tempFolder = string.Empty;
                string filename = imageFile;
                bool isExistImage = false;
                var resizeSetings = new ResizeSettings();
                resizeSetings.Format = "jpg";
                resizeSetings.Mode = FitMode.Max;
                switch (type)
                {
                    case ImageType.Large:
                        {
                            isExistImage = CheckIfImageExists(ImageType.Large, filename);
                            if (!(isExistImage))
                            {
                               ImageSettings imgStng=new ImageSettings(aspxCommonObj);
                               resizeSetings.MaxWidth = imgStng.itemLargeThumbNailWidth;
                               resizeSetings.MaxHeight = imgStng.itemLargeThumbNailHeight;
                               copyOriginalImageToRespectives(ImageType.Large, filename, resizeSetings,disposeSource, addFileExtensions);
                            }
                            break;
                        }
                    case ImageType.Medium:
                        {
                            isExistImage = CheckIfImageExists(ImageType.Medium, filename);
                            if (!(isExistImage))
                            {
                                ImageSettings imgStng = new ImageSettings(aspxCommonObj);
                                resizeSetings.MaxWidth = imgStng.itemMediumThumbNailWidth;
                                resizeSetings.MaxHeight = imgStng.itemMediumThumbNailHeight;
                                copyOriginalImageToRespectives(ImageType.Medium, filename, resizeSetings, disposeSource, addFileExtensions);
                            }
                            break;
                        }
                    case ImageType.Small:
                        {
                            isExistImage = CheckIfImageExists(ImageType.Medium, filename);
                            if (!(isExistImage))
                            {
                                ImageSettings imgStng = new ImageSettings(aspxCommonObj);
                                resizeSetings.MaxWidth = imgStng.itemSmallThumbNailWidth;
                                resizeSetings.MaxHeight = imgStng.itemSmallThumbNailHeight;
                                copyOriginalImageToRespectives(ImageType.Medium, filename, resizeSetings, disposeSource, addFileExtensions);
                            }
                            break;
                        }

                }

            }
            catch
            {
            }
        }
예제 #3
0
        public static void ImageBuilder(string imageFile, ImageType type, bool IsInTempFolder, AspxCommonInfo aspxCommonObj)
        {
            try
            {
                bool   disposeSource     = true;
                bool   addFileExtensions = true;
                string tempFolder        = string.Empty;
                string filename          = imageFile;
                bool   isExistImage      = false;
                var    resizeSetings     = new ResizeSettings();
                resizeSetings.Format = "jpg";
                resizeSetings.Mode   = FitMode.Max;
                switch (type)
                {
                case ImageType.Large:
                {
                    isExistImage = CheckIfImageExists(ImageType.Large, filename);
                    if (!(isExistImage))
                    {
                        ImageSettings imgStng = new ImageSettings(aspxCommonObj);
                        resizeSetings.MaxWidth  = imgStng.itemLargeThumbNailWidth;
                        resizeSetings.MaxHeight = imgStng.itemLargeThumbNailHeight;
                        copyOriginalImageToRespectives(ImageType.Large, filename, resizeSetings, disposeSource, addFileExtensions);
                    }
                    break;
                }

                case ImageType.Medium:
                {
                    isExistImage = CheckIfImageExists(ImageType.Medium, filename);
                    if (!(isExistImage))
                    {
                        ImageSettings imgStng = new ImageSettings(aspxCommonObj);
                        resizeSetings.MaxWidth  = imgStng.itemMediumThumbNailWidth;
                        resizeSetings.MaxHeight = imgStng.itemMediumThumbNailHeight;
                        copyOriginalImageToRespectives(ImageType.Medium, filename, resizeSetings, disposeSource, addFileExtensions);
                    }
                    break;
                }

                case ImageType.Small:
                {
                    isExistImage = CheckIfImageExists(ImageType.Medium, filename);
                    if (!(isExistImage))
                    {
                        ImageSettings imgStng = new ImageSettings(aspxCommonObj);
                        resizeSetings.MaxWidth  = imgStng.itemSmallThumbNailWidth;
                        resizeSetings.MaxHeight = imgStng.itemSmallThumbNailHeight;
                        copyOriginalImageToRespectives(ImageType.Medium, filename, resizeSetings, disposeSource, addFileExtensions);
                    }
                    break;
                }
                }
            }
            catch
            {
            }
        }
예제 #4
0
        /// <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
            {
            }
        }
        public void AddImagesForStoreSettings(string storeSettingImageFolder, string fileName, string largeImageFolder, string mediumImageFolder, string smallImageFolder, AspxCommonInfo aspxCommonObj)
        {
            //Copy resized noitemImage and storelogo Image to the respective folders
            ResizeSettings resizeSetings = new ResizeSettings();
            resizeSetings.Format = "jpg";
            resizeSetings.Mode = FitMode.Carve;
            resizeSetings.Scale = ScaleMode.Both;
            resizeSetings.Quality = 75;
            ImageSettings imgStng = new ImageSettings(aspxCommonObj);
            ResizeSettings resizeSettingsLarge = new ResizeSettings(resizeSetings);
            ResizeSettings resizeSettingsMedium = new ResizeSettings(resizeSetings);
            ResizeSettings resizeSettingsSmall = new ResizeSettings(resizeSetings);
            if (Convert.ToBoolean(imgStng.ResizeImagesProportionally) == true)
            {
                resizeSettingsLarge.Width = imgStng.ItemLargeThumbNailWidth;
                resizeSettingsMedium.Width = imgStng.ItemMediumThumbNailWidth;
                resizeSettingsSmall.Width = imgStng.ItemSmallThumbNailWidth;

            }
            else
            {
                resizeSettingsLarge.Width = imgStng.ItemLargeThumbNailWidth;
                resizeSettingsLarge.Height = imgStng.ItemLargeThumbNailHeight;
                resizeSettingsMedium.Width = imgStng.ItemMediumThumbNailWidth;
                resizeSettingsMedium.Height = imgStng.ItemMediumThumbNailHeight;
                resizeSettingsSmall.Width = imgStng.ItemSmallThumbNailWidth;
                resizeSettingsSmall.Height = imgStng.ItemSmallThumbNailHeight;
                
            }
            copyOriginalImageToRespectives(resizeSettingsSmall, Path.Combine(storeSettingImageFolder, fileName), Path.Combine(smallImageFolder,fileName),aspxCommonObj,IsWaterMark.False);
            copyOriginalImageToRespectives(resizeSettingsMedium, Path.Combine(storeSettingImageFolder, fileName), Path.Combine(mediumImageFolder, fileName),aspxCommonObj, IsWaterMark.False);
            copyOriginalImageToRespectives(resizeSettingsLarge, Path.Combine(storeSettingImageFolder, fileName), Path.Combine(largeImageFolder, fileName),aspxCommonObj, IsWaterMark.False);

        }
        /// <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
            {

            }
        }