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); }
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); }
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"); }
public ImageProcessAddedEvent(ILogger logger, ImageProcessModel imageProcessModel) : base(logger) { ImageProcessModel = imageProcessModel; }
public AddImageProcessCommand(User userLoggedIn, ImageProcessModel imageProcessModel) : base(userLoggedIn) { ImageProcessModel = imageProcessModel; }