AV1 Image File Format (.avif)
.avif file signature | image/avif
AV1 Image File Format (AVIF) is a still-image file format developed and maintained by the Alliance for Open Media, based on the AV1 video codec. It is used for web graphics, digital photography, and other images where efficient compression and support for modern image features are required. AVIF is a current standard and is generally considered safe, though, like any image format, files from untrusted sources should be handled with updated software.
Magic Bytes
Offset 4
66 74 79 70 61 76 69 66
Sources: Apache Tika, Gary Kessler
Extension
.avif
MIME Type
image/avif
Byte Offset
4
Risk Level
Safe
Validation Code
How to validate .avif files in Python
def is_avif(file_path: str) -> bool:
"""Check if file is a valid AVIF by magic bytes at offset 4."""
signature = bytes([0x66, 0x74, 0x79, 0x70, 0x61, 0x76, 0x69, 0x66])
with open(file_path, "rb") as f:
f.seek(4)
return f.read(8) == signature
How to validate .avif files in Node.js
function isAVIF(buffer: Buffer): boolean {
const signature = Buffer.from([0x66, 0x74, 0x79, 0x70, 0x61, 0x76, 0x69, 0x66]);
if (buffer.length < 12) return false;
return buffer.subarray(4, 12).equals(signature);
}
How to validate .avif files in Go
func IsAVIF(data []byte) bool {
signature := []byte{0x66, 0x74, 0x79, 0x70, 0x61, 0x76, 0x69, 0x66}
if len(data) < 12 {
return false
}
return bytes.Equal(data[4:12], signature)
}
API Endpoint
/api/v1/avif
curl https://filesignature.org/api/v1/avif
See the full API documentation for all endpoints and parameters.
Related Formats
Frequently Asked Questions
What is a .avif file?
A .avif file is a AV1 Image File Format file. AV1 Image File Format (AVIF) is a still-image file format developed and maintained by the Alliance for Open Media, based on the AV1 video codec. It is used for web graphics, digital photography, and other images where efficient compression and support for modern image features are required. AVIF is a current standard and is generally considered safe, though, like any image format, files from untrusted sources should be handled with updated software.
What are the magic bytes for .avif files?
The magic bytes for AV1 Image File Format files are 66 74 79 70 61 76 69 66 at byte offset 4. These bytes uniquely identify the file format regardless of the file extension.
How do I validate a .avif file?
To validate a .avif file, read the first bytes of the file and compare them against the known magic bytes (66 74 79 70 61 76 69 66) at offset 4. This is more reliable than checking the file extension alone, as extensions can be renamed.
What is the MIME type for .avif files?
The primary MIME type for .avif files is image/avif.
Is it safe to open .avif files?
AV1 Image File Format (.avif) files are generally safe to open. They are classified as low risk because they primarily contain data rather than executable code. However, always ensure files come from a trusted source.