AVIF (.avif)
Background & Context
-
- MIME type: image/avif
- AVIF raster image and compression format.
- Commonly used for storing still or animated images.
- AVIF is an acronym for AV1 Image File Format.
- Binary format.
- Supports RGB color space.
- Supports up to 12 bits per color channel.
- AVIF support is available in all major web browsers.
- Developed by Alliance for Open Media.
Import & Export
- Import["file.avif"] imports an AVIF file, returning a single Image object or a list of images.
- Import["file.avif",elem] imports the specified element from an AVIF file.
- The import format can be specified with Import["file","AVIF"] or Import["file",{"AVIF",elem,…}].
- Export["file.avif",expr] exports the expression expr to AVIF.
- The expression expr can be any of the following:
-
image an Image expression graphics rasterized graphics expr an arbitrary expression, rasterized {expr1,expr2,…} an animation of rasterized expressions AnimatedImage[…] an animation of an AnimatedImage frame Manipulate[…] an animation of a Manipulate expression - When exporting graphics or arbitrary expressions, the resulting image has the same raster size as its displayed form.
- Image objects are by default exported at their raster size.
- See the following reference pages for full general information:
-
Import, Export import from or export to a file CloudImport, CloudExport import from or export to a cloud object ImportString, ExportString import from or export to a string ImportByteArray, ExportByteArray import from or export to a byte array
Import Elements
- General Import elements:
-
"Elements" list of elements and options available in this file "Summary" summary of the file "Rules" list of rules for all available elements - Data representation elements:
-
"AnimatedImage" animated AVIF represented as an AnimatedImage object "Data" array of pixel values "Graphics" raster image, given as a Graphics object "Image" raster image, given as an Image object "Thumbnail" small thumbnail version of the image {"Thumbnail",size} thumbnail using the specified size - For multiframe AVIF files, the following elements can access different frames and their properties:
-
"GraphicsList" a list of graphics "ImageCount" number of stored frames "ImageList" a list of images "ThumbnailList" a list of thumbnail images - Import by default uses the "Image" element for a static AVIF and "ImageList" for an animated AVIF.
- Export by default generates an animated AVIF if the expression supplied is a list of images or a Manipulate, and a static AVIF otherwise.
- Advanced Import elements:
-
AnimationRepetitions how many times the animation is played before stopping "BitDepth" bits used to represent each color channel in the file "CameraTopOrientation" orientation of the camera when the picture was taken "Channels" the number of color channels used in the file "ColorProfileData" embedded color profile, given as a ColorProfileData object "ColorSpace" color encoding used in the file "DisplayDurations" display durations of animation frames, given in seconds "FlashUsed" whether the flash was fired "GeoPosition" latitude and longitude represented as a GeoPosition object "GPSDateTime" image creation date and time registered by GPS "ImageKeyframeInfo" keyframe information "RasterSize" raster dimensions "RedEyeCorrection" whether a red-eye correction was performed "Summary" summary of the file "SummarySlideView" slide view summary of all frames - Metadata elements:
-
"Exif" formatted Exif (Exchange image file format) "XMP" formatted XMP (Extensible metadata platform) "MetaInformation" combination of all formatted metadata present in the file - Raw metadata, as stored in the file, can be imported using "RawExif" and "RawXMP", which is returned as an association.
- All Exif and XMP tags can be imported individually. Common tags include:
-
"ApertureValue" lens aperture "DateTime" image creation date and time "ExposureTime" exposure time, given in seconds "FlashInfo" flash information: flash fired, red-eye correction, etc. "FNumber" F number "FocalLength" actual focal length of the lens, given in millimeters "GPSAltitude" altitude of the GPS position "GPSLatitude" latitude of the GPS position "GPSLongitude" longitude of the GPS position "Make" manufacturer of the recording equipment "Model" model name or model number of the equipment "Software" name and version of the software or firmware of the camera or image input device used to generate the image
Import Options
- Import options include:
-
ImageResolution Automatic resolution values for import "ImageTopOrientation" Automatic orientation of the image as stored in the file IncludeMetaInformation All whether to import metadata RasterSize Automatic dimensions of the image - Possible settings for "ImageTopOrientation" are Automatic, Top, Bottom, Left or Right.
Export Options
- Export to AVIF has the same options as Rasterize, with the following additions and changes:
-
CompressionLevel 0 compression level, given as a number between 0 and 1 "ImageTopOrientation" Automatic orientation of the image as stored in the file IncludeMetaInformation Automatic metadata types to import and export RasterSize Automatic dimensions of the image "YUVFormat" "4:2:2" chroma subsampling - The following settings for "YUVFormat" are supported:
-
"4:0:0" only luminance (grayscale images) "4:2:0" horizontally and vertically subsampled chroma "4:2:2" horizontally subsampled chroma "4:4:4" no reduction - Export options for animated AVIFs:
-
AnimationRepetitions Infinity how many times the animation plays before stopping "DisplayDurations" Automatic display duration for each frame in seconds - "DisplayDurations"->{d1,d2,…} specifies the display durations for each frame in an animated AVIF.
Examples
open all close allBasic Examples (4)
Scope (9)
Import (3)
Import["ExampleData/sample.avif", "Graphics"]Head[%]Import["ExampleData/sample.avif", "RasterSize"]Import["ExampleData/sample.avif", {{"Model", "ExposureProgram"}}]Export (6)
Export["image.avif", [image]]Export["plot.avif", [image]]Export an arbitrary expression that gets rasterized:
Export["expr.avif", Nest[Subsuperscript[#, #, #]&, o, 4]];Import["expr.avif"]Create an animated AVIF file from a list of images:
Export["animated.avif", {[image], [image], [image], [image], [image]}]Create an animated AVIF file from an AnimatedImage object:
anim = AnimatedImage["ExampleData/pearls.png"];Export["animated.avif", anim]Create an animated AVIF from a Manipulate:
m = Manipulate[Blur[[image], r], {r, 1, 10, 1}]Export["blur.avif", m]Read the number of exported frames:
Import["blur.avif", "ImageCount"]Import Elements (34)
Available Elements (2)
Data Representation (9)
"AnimatedImage" (1)
Import the image sequence as an AnimatedImage:
Import["ExampleData/animation.avif", "AnimatedImage"]"Data" (1)
"Graphics" (1)
Import as a Graphics object:
Import["ExampleData/sample.avif", "Graphics"]Head[%]"GraphicsList" (1)
Import the data as a list of Graphics objects:
images = Import["ExampleData/animation.avif", "GraphicsList"];
RandomSample[images, 3]Head /@ %"Image" (1)
Import as an Image object:
Import["ExampleData/sample.avif", "Image"]Head[%]This is the default import element for static AVIF:
Import["ExampleData/sample.avif"]"ImageList" (2)
Import the data as a list of Image objects:
images = Import["ExampleData/animation.avif", "ImageList"];
RandomSample[images, 3]This is the default import element for animated AVIF:
Head /@ Import["ExampleData/animation.avif"]Import["ExampleData/animation.avif", {"ImageList", Range[3]}]"Thumbnail" (1)
Metadata (23)
"AnimationRepetitions" (1)
"BitDepth" (1)
"CameraTopOrientation" (1)
"Channels" (1)
"ColorProfileData" (1)
Get the embedded color profile, given as a ColorProfileData object:
Import["ExampleData/sample.avif", "ColorProfileData"]The color profile is stored in the ColorSpace option of the imported image:
Options[Import["ExampleData/sample.avif"], ColorSpace]"ColorSpace" (1)
Get the color encoding used on export:
Import["ExampleData/sample.avif", "ColorSpace"]Use ImageColorSpace to get the color space of an imported image:
Import["ExampleData/sample.avif"]//ImageColorSpace"Exif" (3)
Import["ExampleData/sample.avif", "Exif"]Extract an individual tag from the association:
Import["ExampleData/sample.avif", "Exif"]["Image", "Model"]Individual Exif tags can also be imported directly:
Import["ExampleData/sample.avif", "Model"]Some Exif tags are processed to give more detailed information:
Import["ExampleData/sample.avif", "Orientation"]Compare with the raw "Orientation" tag:
Import["ExampleData/sample.avif", "RawExif"]["Image", "Orientation"]"FlashUsed" (1)
"GPSDateTime" (1)
"ImageCount" (1)
"ImageKeyframeInfo" (2)
"MetaInformation" (1)
"RasterSize" (2)
Get the dimensions of the image stored in the file:
Import["ExampleData/sample.avif", "RasterSize"]Using ImageDimensions on an imported image gives the same result:
Import["ExampleData/sample.avif"]//ImageDimensionsSpecify the raster size of the imported image with the RasterSize option:
Import["ExampleData/sample.avif", RasterSize -> 100]//ImageDimensions"RawExif" (1)
Import["ExampleData/sample.avif", "RawExif"]Raw Exif tags return the actual values stored in the file:
Import["ExampleData/sample.avif", "RawExif"]["Image", "ExposureProgram"]When importing "Exif", most tags are processed:
Import["ExampleData/sample.avif", "Exif"]["Image", "ExposureProgram"]"RawXMP" (1)
"RedEyeCorrection" (1)
"Summary" (1)
"SummarySlideView" (1)
Import Options (5)
ImageResolution (1)
By default, the image resolution is extracted from the file:
Options[Import["ExampleData/sample.avif"], ImageResolution]Specify the resolution of the imported image:
Options[Import["ExampleData/sample.avif", ImageResolution -> 144], ImageResolution]Specify different resolutions in
and
directions:
Options[Import["ExampleData/sample.avif", ImageResolution -> {72, 144}], ImageResolution]"ImageTopOrientation" (1)
IncludeMetaInformation (2)
By default, all available metadata is imported:
Options[Import["ExampleData/sample.avif"], MetaInformation]Possible classes of metadata for AVIF files are "Exif" and "XMP":
Options[Import["ExampleData/sample.avif"], MetaInformation][[1, 2]]//KeysImport the image with no metadata:
Options[Import["ExampleData/sample.avif", IncludeMetaInformation -> None], MetaInformation]Export Options (6)
AnimationRepetitions (1)
By default, animation is set to be repeated infinitely:
anim = AnimatedImage[{[image], [image], [image], [image], [image]}];Export["animated.avif", anim]Import["animated.avif", "AnimationRepetitions"]Specify the number of repetitions:
Export["animated.avif", anim, AnimationRepetitions -> 2]Import["animated.avif", "AnimationRepetitions"]CompressionLevel (1)
By default, no compression is used during export:
i = [image];FileByteCount@Export["image.avif", i]A larger CompressionLevel can decrease the file size:
FileByteCount@Export["image2.avif", i, CompressionLevel -> 0.8]Notice the decreased quality of the exported image:
Import["image2.avif"]Compare the change in file size and quality difference using different compression levels:
t = Table[{FileSize[Export["file.avif", i, CompressionLevel -> level]], ImageDistance[Import["file.avif"], i]}, {level, 0, 1, .05}];ListLinePlot[Transpose[t], ...]"DisplayDurations" (1)
By default, a fixed duration is used for all frames:
anim = ConstantImage[#, 50]& /@ {Red, Green, Blue, Black}Export["animated.avif", anim]Import["animated.avif", "DisplayDurations"]Specify the duration of each frame:
Export["animated.avif", anim, "DisplayDurations" -> {.1, .2, .3, .4}]Import["animated.avif", "DisplayDurations"]"ImageTopOrientation" (1)
By default, the upright image is exported using "ImageTopOrientation"->Top:
i = [image];Export["test.avif", i]Import[%]Specify top orientation of the exported image:
Export["test.avif", i, "ImageTopOrientation" -> Left]Import[%]RasterSize (1)
By default, the image is exported in the full resolution:
i = [image];ImageDimensions[i]Export["test.avif", i]Import[%, "RasterSize"]Specify the raster size of the exported image:
Export["test.avif", i, RasterSize -> 47]Import[%, "RasterSize"]"YUVFormat" (1)
By default, "4:2:2" format is used:
i = [image];Export["image1.avif", i]Disable chroma subsampling using "YUVFormat""4:4:4":
Export["image2.avif", i , "YUVFormat" -> "4:4:4"]Compare the quality difference:
ImageDistance[Import["image1.avif"], i]ImageDistance[Import["image2.avif"], i]Tech Notes
Related Guides
History
Introduced in 2025 (14.3) | Updated in 2026 (15.0)