using System; using System.IO; using ImageMagick; class Program { static void Main(string[] args) { string inputFolder; if (args.Length > 0) { inputFolder = args[0]; } else { Console.Write("Enter the path to the folder containing HEIC images: "); inputFolder = Console.ReadLine()!; } if (!Directory.Exists(inputFolder)) { Console.WriteLine($"Error: The folder '{inputFolder}' does not exist."); return; } // Create an output subfolder string outputFolder = Path.Combine(inputFolder, "Converted_JPGs"); Directory.CreateDirectory(outputFolder); // Get all .heic and .HEIC files string[] files = Directory.GetFiles(inputFolder, "*.heic", SearchOption.TopDirectoryOnly); Console.WriteLine($"Found {files.Length} HEIC file(s) in '{inputFolder}'."); int converted = 0; foreach (var file in files) { try { using var image = new MagickImage(file); // Optionally set quality (0-100) image.Quality = 90; // Build output filename string fileName = Path.GetFileNameWithoutExtension(file) + ".jpg"; string outputPath = Path.Combine(outputFolder, fileName); image.Write(outputPath, MagickFormat.Jpeg); converted++; Console.WriteLine($"Converted: {file} -> {outputPath}"); } catch (Exception ex) { Console.WriteLine($"Failed to convert '{file}': {ex.Message}"); } } Console.WriteLine($"Done. Converted {converted}/{files.Length} images. Output folder: {outputFolder}"); } }