Пример #1
0
        private ISupportedImageFormat GetOutputFormat(ImageProcessModel image)
        {
            //ImageProcessor.Imaging.Formats
            switch (image.Extension)
            {
            case ".jpg":
            case ".jpeg":
                return(new JpegFormat());

            case ".png":
                return(new PngFormat());

            case ".tiff":
                return(new TiffFormat());

            case ".bmp":
                return(new BitmapFormat());

            case ".gif":
                return(new GifFormat());

            case ".webp":
                return(new WebPFormat());
            }


            return(null);
        }
Пример #2
0
        public bool ConvertImage(ImageProcessModel sourceModel, ImageProcessModel destinationModel)
        {
            try
            {
                var imgData = factory.Load(sourceModel.FilePath);

                factory.Quality(applicationSettings.JpegImageQuality);
                imgData.Format(GetOutputFormat(destinationModel));
                imgData.Save(destinationModel.FilePath);

                if (!File.Exists(destinationModel.FilePath))
                {
                    return(false);
                }

                var fi = new FileInfo(destinationModel.FilePath);
                destinationModel.FileSize  = fi.Length;
                destinationModel.Extension = fi.Extension;
                destinationModel.FileName  = fi.Name;
            }
            catch (Exception ex)
            {
                Log.Error(ex, "ConvertImage Exception");
                return(false);
            }


            return(true);
        }
Пример #3
0
 public ToDownloadListViewModel()
 {
     searchModel = new SearchImageModel(Environment.CurrentDirectory + "/cache");
     searchModel.CollectionChanged            += OnCollectionChanged;
     imageProcessModel                         = new ImageProcessModel(Environment.CurrentDirectory + "/processcache");
     imageProcessModel.OnProcessedImageChange += () => { OnPropertyChanged(new PropertyChangedEventArgs(nameof(ProcessedImage))); };
     outputdDirectory = System.IO.Path.Combine(Environment.CurrentDirectory, "out");
 }
Пример #4
0
 public ImageProcessAddedEvent(ILogger logger, ImageProcessModel imageProcessModel)
     : base(logger)
 {
     ImageProcessModel = imageProcessModel;
 }
Пример #5
0
 public AddImageProcessCommand(User userLoggedIn, ImageProcessModel imageProcessModel)
     : base(userLoggedIn)
 {
     ImageProcessModel = imageProcessModel;
 }