From ea22f9fb65a17dd3052e99b841bbb4d77492490f Mon Sep 17 00:00:00 2001 From: RTnhN <43109787+RTnhN@users.noreply.github.com> Date: Sun, 24 Nov 2024 00:12:02 -0600 Subject: [PATCH] Implement gif to img conversion --- .../FileConverter/ConversionJobs/ConversionJobFactory.cs | 5 +++-- .../ConversionJobs/ConversionJob_ImageMagick.cs | 6 ++++++ Application/FileConverter/Helpers.cs | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Application/FileConverter/ConversionJobs/ConversionJobFactory.cs b/Application/FileConverter/ConversionJobs/ConversionJobFactory.cs index 9791a66..7b20167 100644 --- a/Application/FileConverter/ConversionJobs/ConversionJobFactory.cs +++ b/Application/FileConverter/ConversionJobs/ConversionJobFactory.cs @@ -43,8 +43,9 @@ namespace FileConverter.ConversionJobs return new ConversionJob_ImageMagick(conversionPreset, inputFilePath); } - if (Helpers.GetExtensionCategory(inputFileExtension) == Helpers.InputCategoryNames.Image || - Helpers.GetExtensionCategory(inputFileExtension) == Helpers.InputCategoryNames.Document) + if (conversionPreset.OutputType == OutputType.Jpg || + conversionPreset.OutputType == OutputType.Png || + conversionPreset.OutputType == OutputType.Webp) { return new ConversionJob_ImageMagick(conversionPreset, inputFilePath); } diff --git a/Application/FileConverter/ConversionJobs/ConversionJob_ImageMagick.cs b/Application/FileConverter/ConversionJobs/ConversionJob_ImageMagick.cs index 1c95dff..725ba8d 100644 --- a/Application/FileConverter/ConversionJobs/ConversionJob_ImageMagick.cs +++ b/Application/FileConverter/ConversionJobs/ConversionJob_ImageMagick.cs @@ -86,6 +86,12 @@ namespace FileConverter.ConversionJobs readSettings.Format = MagickFormat.Dng; break; + case ".gif": + // Get the first frame of the gif for conversion. + // Maybe in the future make this user selectable. + readSettings.FrameIndex = 0; + break; + default: break; } diff --git a/Application/FileConverter/Helpers.cs b/Application/FileConverter/Helpers.cs index c86ca27..35c8fcb 100644 --- a/Application/FileConverter/Helpers.cs +++ b/Application/FileConverter/Helpers.cs @@ -216,7 +216,7 @@ namespace FileConverter case OutputType.Jpg: case OutputType.Png: case OutputType.Webp: - return category == InputCategoryNames.Image || category == InputCategoryNames.Document; + return category == InputCategoryNames.Image || category == InputCategoryNames.Document || category == InputCategoryNames.AnimatedImage; case OutputType.Gif: return category == InputCategoryNames.Image || category == InputCategoryNames.Video || category == InputCategoryNames.AnimatedImage;