示例#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;
 }