diff --git a/internal/magic/ftyp.go b/internal/magic/ftyp.go index a23d2b76..27a60e10 100644 --- a/internal/magic/ftyp.go +++ b/internal/magic/ftyp.go @@ -1,6 +1,10 @@ package magic var ( + // AVIF matches an AV1 Image File Format still or animated. + // Wikipedia page seems outdated listing image/avif-sequence for animations. + // https://github.com/AOMediaCodec/av1-avif/issues/59 + AVIF = ftyp([]byte("avif"), []byte("avis")) // Mp4 matches an MP4 file. Mp4 = ftyp( []byte("avc1"), []byte("dash"), []byte("iso2"), []byte("iso3"), diff --git a/mimetype_test.go b/mimetype_test.go index 1e33ccde..76021cd8 100644 --- a/mimetype_test.go +++ b/mimetype_test.go @@ -34,6 +34,8 @@ var files = map[string]string{ "atom.atom": "application/atom+xml", "au.au": "audio/basic", "avi.avi": "video/x-msvideo", + "avif.avif": "image/avif", + "avifsequence.avif": "image/avif", "bmp.bmp": "image/bmp", "bpg.bpg": "image/bpg", "bz2.bz2": "application/x-bzip2", diff --git a/supported_mimes.md b/supported_mimes.md index f67f475b..926e9a3e 100644 --- a/supported_mimes.md +++ b/supported_mimes.md @@ -1,4 +1,4 @@ -## 165 Supported MIME types +## 166 Supported MIME types This file is automatically generated when running tests. Do not edit manually. Extension | MIME type | Aliases @@ -135,6 +135,7 @@ Extension | MIME type | Aliases **.pat** | image/x-gimp-pat | - **.gbr** | image/x-gimp-gbr | - **.glb** | model/gltf-binary | - +**.avif** | image/avif | - **.txt** | text/plain | - **.html** | text/html | - **.svg** | image/svg+xml | - diff --git a/testdata/avif.avif b/testdata/avif.avif new file mode 100644 index 00000000..6e4f3433 Binary files /dev/null and b/testdata/avif.avif differ diff --git a/testdata/avifsequence.avif b/testdata/avifsequence.avif new file mode 100644 index 00000000..89878c0c Binary files /dev/null and b/testdata/avifsequence.avif differ diff --git a/tree.go b/tree.go index e5466f13..7d1dbf5f 100644 --- a/tree.go +++ b/tree.go @@ -24,7 +24,7 @@ var root = newMIME("application/octet-stream", "", gzip, class, swf, crx, ttf, woff, woff2, otf, eot, wasm, shx, dbf, dcm, rar, djvu, mobi, lit, bpg, sqlite3, dwg, nes, lnk, macho, qcp, icns, heic, heicSeq, heif, heifSeq, hdr, mrc, mdb, accdb, zstd, cab, rpm, xz, lzip, - torrent, cpio, tzif, xcf, pat, gbr, glb, + torrent, cpio, tzif, xcf, pat, gbr, glb, avif, // Keep text last because it is the slowest check text, ) @@ -133,6 +133,7 @@ var ( heif = newMIME("image/heif", ".heif", magic.Heif) heifSeq = newMIME("image/heif-sequence", ".heif", magic.HeifSequence) hdr = newMIME("image/vnd.radiance", ".hdr", magic.Hdr) + avif = newMIME("image/avif", ".avif", magic.AVIF) mp3 = newMIME("audio/mpeg", ".mp3", magic.Mp3). alias("audio/x-mpeg", "audio/mp3") flac = newMIME("audio/flac", ".flac", magic.Flac)