private static IFileFormat GetImageFormatFromImageFormat(System.Drawing.Imaging.ImageFormat imageFormat) { if (imageFormat.Equals(System.Drawing.Imaging.ImageFormat.Bmp)) { return(FileFormat.FromFileExtension(".bmp")); } else if (imageFormat.Equals(System.Drawing.Imaging.ImageFormat.Gif)) { return(FileFormat.FromFileExtension(".gif")); } else if (imageFormat.Equals(System.Drawing.Imaging.ImageFormat.Exif)) { return(FileFormat.FromFileExtension(".exif")); } else if (imageFormat.Equals(System.Drawing.Imaging.ImageFormat.Jpeg)) { return(ImageFormat.Jpeg); } else if (imageFormat.Equals(System.Drawing.Imaging.ImageFormat.Png)) { return(ImageFormat.Png); } else if (imageFormat.Equals(System.Drawing.Imaging.ImageFormat.Tiff)) { return(FileFormat.FromFileExtension(".tiff")); } else { return(null); } }
private static IFileFormat GetImageFormatFromMagickFormat(MagickFormat magickFormat) { string ext = ImageMagickUtilities.GetFileExtensionFromMagickFormat(magickFormat); if (string.IsNullOrEmpty(ext)) { throw new UnsupportedFileFormatException(); } return(FileFormat.FromFileExtension(ext)); }
public static void Save(this IImage image, string filePath, IImageEncoderOptions encoderOptions) { IFileFormat imageFormat = FileFormat.FromFileExtension(filePath); if (imageFormat is null) { throw new UnsupportedFileFormatException(); } image.Save(filePath, imageFormat, encoderOptions); }
public static IImageCodec FromFileExtension(string filePath) { string ext = PathUtilities.GetFileExtension(filePath); if (string.IsNullOrWhiteSpace(ext)) { return(null); } return(FromFileFormat(FileFormat.FromFileExtension(ext))); }
public static bool IsNativelySupportedImageFormat(string filePath) { string ext = PathUtilities.GetFileExtension(filePath).ToLowerInvariant(); if (string.IsNullOrWhiteSpace(ext)) { return(false); } return(IsNativelySupportedImageFormat(FileFormat.FromFileExtension(ext))); }
public static bool IsSupportedFileFormat(this IHasSupportedFileFormats obj, string filePath) { string ext = PathUtilities.GetFileExtension(filePath).ToLowerInvariant(); if (string.IsNullOrWhiteSpace(ext)) { return(false); } return(obj.IsSupportedFileFormat(FileFormat.FromFileExtension(ext))); }
private static IEnumerable <IFileFormat> GetNativelySupportedImageFormats() { return(new List <string>(new[] { ".bmp", ".gif", ".exif", ".jpg", ".jpeg", ".png", ".tif", ".tiff" }).OrderBy(type => type) .Select(ext => FileFormat.FromFileExtension(ext)) .Distinct()); }
private static IEnumerable <IFileFormat> GetSupportedImageFormats() { return(new[] { ".avif", ".bmp", ".gif", ".jpg", ".jpeg", ".png", ".tif", ".tiff", ".webp", }.OrderBy(ext => ext) .Select(ext => FileFormat.FromFileExtension(ext)) .Distinct()); }
// Private members private IEnumerable <IFileFormat> GetSupportedImageFormats() { return(new[] { ".png" }.Select(ext => FileFormat.FromFileExtension(ext))); }