Пример #1
0
        public static async Task ConvertToFlif(string path, int q, bool delSrc)
        {
            long   bytesSrc = new FileInfo(path).Length;
            string outPath  = Path.ChangeExtension(path, null) + ".flif";

            if (await Config.GetInt("flifEnc") == 1)
            {
                await FlifInterface.EncodeImage(path, q, delSrc);
            }
            else
            {
                await ConvertToFlifMagick(path, q, delSrc);
            }

            PostProcessing(path, outPath, bytesSrc, delSrc);
        }
Пример #2
0
        public static async void ConvertDirToFlif(bool useFlifExe, 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++;
                if (useFlifExe)
                {
                    FlifInterface.EncodeImage(file.FullName, q, delSrc);
                }
                else
                {
                    ConvertToFlif(file.FullName, q, delSrc);
                }
                await Program.PutTaskDelay();
            }
            Program.PostProcessing();
        }
Пример #3
0
        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);
                    }
                }
            }
        }
Пример #4
0
        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);
                    }
                }
            }
        }