Skip to content

Commit

Permalink
Add support for AVIF still and animated
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-vasile committed Nov 18, 2021
1 parent acfd75a commit f4259a3
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions internal/magic/ftyp.go
Original file line number Diff line number Diff line change
@@ -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"),
Expand Down
2 changes: 2 additions & 0 deletions mimetype_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion supported_mimes.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 | -
Expand Down
Binary file added testdata/avif.avif
Binary file not shown.
Binary file added testdata/avifsequence.avif
Binary file not shown.
3 changes: 2 additions & 1 deletion tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f4259a3

Please sign in to comment.