GifMotion by Warren Galyen

<PackageReference Include="GifMotion" Version="1.0.4" />

 Helper

public class Helper
using System; using System.Collections.Generic; using System.Drawing; using System.IO; using System.Linq; namespace GifMotion { public class Helper { public static readonly string[] ImageFileExtensions = new string[9] { "jpg", "jpeg", "png", "apng", "gif", "bmp", "ico", "tif", "tiff" }; public static bool IsImage(string filePath) { return CheckExtension(filePath, ImageFileExtensions); } public static bool CheckExtension(string filePath, IEnumerable<string> extensions) { string ext = GetFilenameExtension(filePath); if (!string.IsNullOrEmpty(ext)) return extensions.Any((string x) => ext.Equals(x, StringComparison.InvariantCultureIgnoreCase)); return false; } public static string GetFilenameExtension(string filePath) { if (!string.IsNullOrEmpty(filePath)) { int num = filePath.LastIndexOf('.'); if (num >= 0) return filePath.Substring(num + 1); } return null; } public static Image LoadImage(string filePath) { try { if (!string.IsNullOrEmpty(filePath) && IsImage(filePath) && File.Exists(filePath)) return Image.FromStream(new MemoryStream(File.ReadAllBytes(filePath))); } catch (Exception ex) { Console.WriteLine(ex.Message); } return null; } public static void CreateDirectoryFromFilePath(string path) { if (!string.IsNullOrEmpty(path)) CreateDirectoryFromDirectoryPath(Path.GetDirectoryName(path)); } public static void CreateDirectoryFromDirectoryPath(string path) { if (!string.IsNullOrEmpty(path) && !Directory.Exists(path)) try { Directory.CreateDirectory(path); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } }