Skip to content

Commit

Permalink
Added functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Nevah5 committed Aug 5, 2024
1 parent 36cb881 commit 9713c7a
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
4 changes: 4 additions & 0 deletions HEIC2PNG.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@
<None Remove="help.txt" />
<EmbeddedResource Include="help.txt" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="13.10.0" />
</ItemGroup>

</Project>
49 changes: 49 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,55 @@
using HEIC2PNG;
using ImageMagick;

if (args.Length == 0 || args[0] == "help")
{
PrintHelp();
return;
}

var inputFile = args[0];
var outputFolder = args.Length == 2 ? args[1] : null;


string filePath = Path.Combine(AppContext.BaseDirectory, inputFile);
if (File.Exists(filePath))
{
ConvertFile(filePath);
} else if (Directory.Exists(filePath))
{
foreach (var file in Directory.GetFiles(filePath))
{
if(!file.EndsWith(".HEIC")) continue;
ConvertFile(file);
}
}
else
{
Console.WriteLine("Error: File or Directory not found. Please check the path or refer to the help page.");
}

return;

void PrintHelp()
{
Console.WriteLine(FileUtils.ReadLocalEmbeddedResource("help.txt"));
}

void ConvertFile(string inputFilePath)
{
var outputFilePath = $"{inputFilePath}.png";
try
{
using (MagickImage image = new MagickImage(inputFilePath))
{
image.Format = MagickFormat.Png;
image.Write(outputFilePath);

Console.WriteLine($"Successfully converted {Path.GetFileName($"{inputFilePath}")} to {Path.GetFileName(outputFilePath)}");
}
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
2 changes: 1 addition & 1 deletion help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
█─█─█▄─▄▄─█▄─▄█─▄▄▄─█▀▄▄▀█▄─▄▄─█▄─▀█▄─▄█─▄▄▄▄█
█─▄─██─▄█▀██─██─███▀██▀▄███─▄▄▄██─█▄▀─██─██▄─█
█▄█▄█▄▄▄▄▄█▄▄▄█▄▄▄▄▄█▄▄▄▄█▄▄▄███▄▄▄██▄▄█▄▄▄▄▄█
By Nevah5 - version develop
By Nevah5 - v1.0.0

HEIC2PNG.exe {input_folder} [output_folder]
Converts all the HEIC images in the specified input folder to PNG.
Expand Down

0 comments on commit 9713c7a

Please sign in to comment.