Exemplo n.º 1
0
        public static GeneretedResult GenerateImages(this HttpPostedFile file, string setting, DateTime uploadDate,
                                                     GenerateIdentityForImageHandler generateIdentityForImageHandler)
        {
            ImagesSetting imgSetting = new ImagesSetting();

            if (setting.ToLower().IndexOf("outputimageformat=pub,") != -1)
            {
                setting = setting.Replace("OutputImageFormat=pub", "OutputImageFormat=" + file.FileName.Substring(file.FileName.LastIndexOf('.') + 1));
            }

            imgSetting = setting.JsonTo(imgSetting);

            return(file.GenerateImages(imgSetting, uploadDate, generateIdentityForImageHandler));
        }
Exemplo n.º 2
0
        public static GeneretedResult GenerateImages(this HttpPostedFile file, ImagesSetting setting, DateTime uploadDate,
                                                     GenerateIdentityForImageHandler generateIdentityForImageHandler)
        {
            GeneretedResult generatedResult = new GeneretedResult();

            ImagesEditor imgEditor = new ImagesEditor(setting);

            generatedResult.Message = imgEditor.GetValidateMessage(file.InputStream);

            if (generatedResult.Message != "")
            {
                return(generatedResult);
            }
            try
            {
                string identity = ImagesEditor.CreateImageIdentity();
                if (generateIdentityForImageHandler != null)
                {
                    identity = generateIdentityForImageHandler(setting.Name, uploadDate);
                }


                if (setting.FixSourceExtention)
                {
                    setting.OutputImageFormat = file.FileName.Substring(file.FileName.LastIndexOf('.') + 1);
                }

                var mainImagePath = ImagesEditor.GetRealImagePath(setting.Path, "Main", uploadDate, identity, setting.OutputImageFormat.ToString());

                file.SaveAs(mainImagePath);

                imgEditor.SaveAndGetPaths(mainImagePath, identity, uploadDate);

                generatedResult.IsSuccessfull = true;
                generatedResult.Identity      = identity;
            }
            catch (Exception ex)
            {
                generatedResult.Message       = ex.Message;
                generatedResult.IsSuccessfull = false;
                generatedResult.Identity      = string.Empty;
            }

            return(generatedResult);
        }
Exemplo n.º 3
0
 public ImagesEditor(ImagesSetting imagesSettings)
 {
     _imageSetting = imagesSettings;
 }
Exemplo n.º 4
0
 public static string GetPath(this string id, ImagesSetting setting, string size, DateTime uploadedDate)
 {
     return(ImagesEditor.GetImagePath(setting.Path, size, uploadedDate, id, setting.OutputImageFormat));
 }
Exemplo n.º 5
0
 public static GeneretedResult GenerateImages(this HttpPostedFile file, ImagesSetting setting)
 {
     return(file.GenerateImages(setting, DateTime.Now, GenerateIdentityForImage));
 }