From 3c8ab9b798f432ff279849928b40d13321a818e1 Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Sun, 4 Feb 2024 21:45:27 +1100 Subject: [PATCH] Add AVIF support Ported from https://github.com/drewnoakes/metadata-extractor/pull/649 --- .../Formats/QuickTime/QuickTimeTypeChecker.cs | 3 +++ MetadataExtractor/ImageMetadataReader.cs | 1 + .../PublicAPI/net462/PublicAPI.Unshipped.txt | 1 + .../netstandard1.3/PublicAPI.Unshipped.txt | 1 + .../netstandard2.1/PublicAPI.Unshipped.txt | 1 + MetadataExtractor/Util/FileType.cs | 13 ++++++++++--- 6 files changed, 17 insertions(+), 3 deletions(-) diff --git a/MetadataExtractor/Formats/QuickTime/QuickTimeTypeChecker.cs b/MetadataExtractor/Formats/QuickTime/QuickTimeTypeChecker.cs index 4636890cd..fa69b6d71 100644 --- a/MetadataExtractor/Formats/QuickTime/QuickTimeTypeChecker.cs +++ b/MetadataExtractor/Formats/QuickTime/QuickTimeTypeChecker.cs @@ -54,6 +54,9 @@ internal sealed class QuickTimeTypeChecker : ITypeChecker { Util.FileType.Heif, "hevc"u8 }, { Util.FileType.Heif, "hevx"u8 }, + // AVIF + { Util.FileType.Avif, "avif"u8 }, + // CRX { Util.FileType.Crx, "crx "u8 } }; diff --git a/MetadataExtractor/ImageMetadataReader.cs b/MetadataExtractor/ImageMetadataReader.cs index 74a31199c..604941fa0 100644 --- a/MetadataExtractor/ImageMetadataReader.cs +++ b/MetadataExtractor/ImageMetadataReader.cs @@ -72,6 +72,7 @@ public static IReadOnlyList ReadMetadata(Stream stream) { FileType.Arw => TiffMetadataReader.ReadMetadata(stream), FileType.Avi => AviMetadataReader.ReadMetadata(stream), + FileType.Avif => HeifMetadataReader.ReadMetadata(stream), FileType.Bmp => BmpMetadataReader.ReadMetadata(stream), FileType.Crx => QuickTimeMetadataReader.ReadMetadata(stream), FileType.Cr2 => TiffMetadataReader.ReadMetadata(stream), diff --git a/MetadataExtractor/PublicAPI/net462/PublicAPI.Unshipped.txt b/MetadataExtractor/PublicAPI/net462/PublicAPI.Unshipped.txt index a572972f7..5751c89ec 100644 --- a/MetadataExtractor/PublicAPI/net462/PublicAPI.Unshipped.txt +++ b/MetadataExtractor/PublicAPI/net462/PublicAPI.Unshipped.txt @@ -69,6 +69,7 @@ MetadataExtractor.Formats.Exif.Makernotes.NikonPictureControl2Directory MetadataExtractor.Formats.Exif.Makernotes.NikonPictureControl2Directory.NikonPictureControl2Directory() -> void MetadataExtractor.IO.IndexedReader.GetByte(int index) -> byte MetadataExtractor.IO.IndexedReader.GetBytes(int index, int count) -> byte[]! +MetadataExtractor.Util.FileType.Avif = 28 -> MetadataExtractor.Util.FileType override MetadataExtractor.Formats.Exif.Makernotes.AppleRunTimeMakernoteDescriptor.GetDescription(int tagType) -> string? override MetadataExtractor.Formats.Exif.Makernotes.AppleRunTimeMakernoteDirectory.Name.get -> string! override MetadataExtractor.Formats.Exif.Makernotes.NikonPictureControl1Descriptor.GetDescription(int tagType) -> string? diff --git a/MetadataExtractor/PublicAPI/netstandard1.3/PublicAPI.Unshipped.txt b/MetadataExtractor/PublicAPI/netstandard1.3/PublicAPI.Unshipped.txt index a572972f7..5751c89ec 100644 --- a/MetadataExtractor/PublicAPI/netstandard1.3/PublicAPI.Unshipped.txt +++ b/MetadataExtractor/PublicAPI/netstandard1.3/PublicAPI.Unshipped.txt @@ -69,6 +69,7 @@ MetadataExtractor.Formats.Exif.Makernotes.NikonPictureControl2Directory MetadataExtractor.Formats.Exif.Makernotes.NikonPictureControl2Directory.NikonPictureControl2Directory() -> void MetadataExtractor.IO.IndexedReader.GetByte(int index) -> byte MetadataExtractor.IO.IndexedReader.GetBytes(int index, int count) -> byte[]! +MetadataExtractor.Util.FileType.Avif = 28 -> MetadataExtractor.Util.FileType override MetadataExtractor.Formats.Exif.Makernotes.AppleRunTimeMakernoteDescriptor.GetDescription(int tagType) -> string? override MetadataExtractor.Formats.Exif.Makernotes.AppleRunTimeMakernoteDirectory.Name.get -> string! override MetadataExtractor.Formats.Exif.Makernotes.NikonPictureControl1Descriptor.GetDescription(int tagType) -> string? diff --git a/MetadataExtractor/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt b/MetadataExtractor/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt index fc56fb047..b1912d67a 100644 --- a/MetadataExtractor/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt +++ b/MetadataExtractor/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt @@ -68,6 +68,7 @@ MetadataExtractor.Formats.Exif.Makernotes.NikonPictureControl2Directory MetadataExtractor.Formats.Exif.Makernotes.NikonPictureControl2Directory.NikonPictureControl2Directory() -> void MetadataExtractor.IO.IndexedReader.GetByte(int index) -> byte MetadataExtractor.IO.IndexedReader.GetBytes(int index, int count) -> byte[]! +MetadataExtractor.Util.FileType.Avif = 28 -> MetadataExtractor.Util.FileType override MetadataExtractor.Formats.Exif.Makernotes.AppleRunTimeMakernoteDescriptor.GetDescription(int tagType) -> string? override MetadataExtractor.Formats.Exif.Makernotes.AppleRunTimeMakernoteDirectory.Name.get -> string! override MetadataExtractor.Formats.Exif.Makernotes.NikonPictureControl1Descriptor.GetDescription(int tagType) -> string? diff --git a/MetadataExtractor/Util/FileType.cs b/MetadataExtractor/Util/FileType.cs index 9fe2c1ca6..a070d1056 100644 --- a/MetadataExtractor/Util/FileType.cs +++ b/MetadataExtractor/Util/FileType.cs @@ -88,7 +88,10 @@ public enum FileType Heif = 26, /// MPEG-4 Part 14. - Mp4 = 27 + Mp4 = 27, + + /// AV1 Image File Format. + Avif = 28 } public static class FileTypeExtensions @@ -122,7 +125,8 @@ public static class FileTypeExtensions "TGA", "MP3", "HEIF", - "MP4" + "MP4", + "AVIF" ]; private static readonly string[] _longNames = @@ -155,6 +159,7 @@ public static class FileTypeExtensions "MPEG Audio Layer III", "High Efficiency Image File Format", "MPEG-4 Part 14", + "AV1 Image File Format", ]; private static readonly string?[] _mimeTypes = @@ -187,6 +192,7 @@ public static class FileTypeExtensions "audio/mpeg", "image/heic", "video/mp4", + "image/avif" ]; private static readonly string[]?[] _extensions = @@ -218,7 +224,8 @@ public static class FileTypeExtensions ["tga", "icb", "vda", "vst"], ["mp3"], ["heic", "heif", "avci"], - ["mp4", "m4a", "m4p", "m4b", "m4r", "m4v"] + ["mp4", "m4a", "m4p", "m4b", "m4r", "m4v"], + ["avif"] ]; public static string GetName(this FileType fileType)