Esempio n. 1
0
        public override void Run(string input, string output, string outputFormat)
        {
            if (!File.Exists(input))
            {
                throw new ArgumentException($"Input file in path '{input}' doesn't exist.");
            }

            var outputPath = GetOutputPath(input, output, outputFormat);

            if (!loader.IsSupportedFile(input))
            {
                var msg = $"Input file '{input}' is not supported.\nSupported input extensions: {string.Join(", ", loader.GetSupportedExtensions())}";
                throw new ArgumentException(msg);
            }

            if (!exporter.IsSupportedFile(outputPath))
            {
                var msg = $"Output file '{outputPath}' is not supported.\nSupported output extensions: {string.Join(", ", exporter.GetSupportedExtensions())}";
                throw new ArgumentException(msg);
            }

            var image = loader.FromFile(input);

            exporter.Export(image, outputPath);
        }
Esempio n. 2
0
 /// <summary>
 /// Registers <paramref name="loader"/> that will be used for loading images accepting all extensions that <paramref name="loader"/> supports.
 /// </summary>
 /// <param name="loader"></param>
 public void RegisterLoader(IImageLoader loader)
 {
     RegisterLoader(loader.GetSupportedExtensions(), loader);
 }