public static async Task ConvertToHeif(string path, int q, bool delSrc) { long bytesSrc = new FileInfo(path).Length; string outPath = Path.ChangeExtension(path, null) + ".heic"; await HeifInterface.EncodeImage(path, q, delSrc); PostProcessing(path, outPath, bytesSrc, delSrc); }
public static async void ConvertDirToHeif(int q, bool delSrc) { int counter = 1; FileInfo[] files = IOUtils.GetFiles(); Program.PreProcessing(); foreach (FileInfo file in files) { Program.ShowProgress("Converting Image ", counter, files.Length); counter++; HeifInterface.EncodeImage(file.FullName, q, delSrc); await Program.PutTaskDelay(); } Program.PostProcessing(); }
public static void ConvertFileList(string[] files, ComboBox qualityCombox, ComboBox qualityMaxCombox, IF selectedFormat, CheckBox delSrcCbox) { int qMin = qualityCombox.GetInt(); int qMax = qMin; if (!string.IsNullOrWhiteSpace(qualityMaxCombox.Text.Trim())) { qMax = qualityMaxCombox.GetInt(); } foreach (string file in files) { Program.Print("\nDropped File: " + Path.GetFileName(file).Truncate(90)); if (!IOUtils.IsPathDirectory(file)) { if (selectedFormat == IF.JPG) { ConvertUtils.ConvertToJpeg(file, qMin, qMax, delSrcCbox.Checked); } if (selectedFormat == IF.PNG) { ConvertUtils.ConvertToPng(file, qMin, delSrcCbox.Checked); } if (selectedFormat == IF.DDS) { if (Config.GetInt("ddsEnc") == 0) { ConvertUtils.ConvertToDds(file, delSrcCbox.Checked); } if (Config.GetInt("ddsEnc") == 1) { DdsInterface.NvCompress(file, Path.ChangeExtension(file, "dds"), delSrcCbox.Checked); } if (Config.GetInt("ddsEnc") == 2) { DdsInterface.Crunch(file, qMin, qMax, delSrcCbox.Checked); } } if (selectedFormat == IF.TGA) { ConvertUtils.ConvertToTga(file, delSrcCbox.Checked); } if (selectedFormat == IF.WEBP) { ConvertUtils.ConvertToWebp(file, qMin, qMax, delSrcCbox.Checked); } if (selectedFormat == IF.J2K) { ConvertUtils.ConvertToJpeg2000(file, qMin, delSrcCbox.Checked); } if (selectedFormat == IF.FLIF) { if (Config.GetInt("flifEnc") == 1) { FlifInterface.EncodeImage(file, qMin, delSrcCbox.Checked); } else { ConvertUtils.ConvertToFlif(file, qMin, delSrcCbox.Checked); } } if (selectedFormat == IF.BMP) { ConvertUtils.ConvertToBmp(file, delSrcCbox.Checked); } if (selectedFormat == IF.AVIF) { ConvertUtils.ConvertToAvif(file, qMin, delSrcCbox.Checked); } if (selectedFormat == IF.HEIF) { HeifInterface.EncodeImage(file, qMin, delSrcCbox.Checked); } } } }
public static async Task ConvertFileList(string[] files, ComboBox qualityCombox, ComboBox qualityMaxCombox, IF selectedFormat, CheckBox delSrcCbox) { int qMin = qualityCombox.GetInt(); int qMax = qMin; if (!string.IsNullOrWhiteSpace(qualityMaxCombox.Text.Trim())) { qMax = qualityMaxCombox.GetInt(); } foreach (string file in files) { Logger.Log("\nDropped File: " + Path.GetFileName(file).Truncate(90)); if (!IOUtils.IsPathDirectory(file)) { if (selectedFormat == IF.JPG) { await ConvertUtils.ConvertToJpeg(file, qMin, qMax, delSrcCbox.Checked); } if (selectedFormat == IF.PNG) { await ConvertUtils.ConvertToPng(file, qMin, delSrcCbox.Checked); } if (selectedFormat == IF.DDS) { await ConvertUtils.ConvertToDds(file, qMin, qMax, delSrcCbox.Checked); } if (selectedFormat == IF.TGA) { await ConvertUtils.ConvertToTga(file, delSrcCbox.Checked); } if (selectedFormat == IF.WEBP) { await ConvertUtils.ConvertToWebp(file, qMin, qMax, delSrcCbox.Checked); } if (selectedFormat == IF.J2K) { await ConvertUtils.ConvertToJpeg2000(file, qMin, delSrcCbox.Checked); } if (selectedFormat == IF.FLIF) { if (await Config.GetInt("flifEnc") == 1) { await FlifInterface.EncodeImage(file, qMin, delSrcCbox.Checked); } else { await ConvertUtils.ConvertToFlif(file, qMin, delSrcCbox.Checked); } } if (selectedFormat == IF.BMP) { await ConvertUtils.ConvertToBmp(file, delSrcCbox.Checked); } if (selectedFormat == IF.AVIF) { await ConvertUtils.ConvertToAvif(file, qMin, delSrcCbox.Checked); } if (selectedFormat == IF.HEIF) { await HeifInterface.EncodeImage(file, qMin, delSrcCbox.Checked); } if (selectedFormat == IF.JXL) { await ConvertUtils.ConvertToJxl(file, qMin, qMax, delSrcCbox.Checked); } } } }