HEIF (.heic, .heif)
Background & Context
-
- MIME type: image/heic, image/heif, image/heic-sequence, image/heif-sequence
- HEIF raster image and compression format.
- Commonly used for storing still or animated images.
- HEIF is an acronym for High Efficiency Image File Format.
- Binary format.
- Supports grayscale and RGB color spaces.
- Supports up to 16 bits per color channel.
- Uses a lossy compression based on discrete cosine transform with varied block sizes.
- Supports different compression levels.
- Developed by Moving Picture Experts Group (MPEG).
- Published as international standard ISO/IEC 23008-12.
Import & Export
- Import["file.heic"] imports a HEIF file, returning a single Image object or a list of images.
- Import["file.heic",elem] imports the specified element from a HEIF file.
- The import format can be specified with Import["file","HEIF"] or Import["file",{"HEIF",elem,…}].
- Export["file.heic",expr] exports expr to HEIF.
- The following expressions are supported:
-
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 import from a file CloudImport import from a cloud object ImportString import from a string ImportByteArray import from 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 HEIF represented as an AnimatedImage object "Data" array of pixel values "EmbeddedThumbnail" embedded thumbnail "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 HEIF files, the following elements can access different frames and their properties:
-
"EmbeddedThumbnailList" a list of embedded thumbnails "GraphicsList" a list of graphics "ImageCount" number of stored frames "ImageList" a list of images "ThumbnailList" a list of thumbnail images - Depth data elements:
-
"DepthImage" depth image associated to the first frame "DepthImageFullSize" depth image resized to the image dimensions - Import by default uses the "Image" element for a static HEIF and "ImageList" for an animated HEIF.
- Advanced Import elements:
-
"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 "EmbeddedThumbnailSize" size of the embedded thumbnail "FlashUsed" whether the flash was fired "GeoPosition" latitude and longitude represented as a GeoPosition object "GPSDateTime" image creation date and time registered by GPS "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 "Artist" photographer or image creator "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 HEIF 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 All whether to import metadata RasterSize Automatic dimensions of the image - Export options for animated HEIFs:
-
"RemoveDuplicatedFrames" False whether to remove duplicated frames
Examples
open all close allBasic Examples (3)
Scope (6)
Import (4)
Import["ExampleData/sample.heic", "Graphics"]Head[%]Import["ExampleData/sample.heic", "ImageSize"]Import["http://exampledata.wolfram.com/bear.heic", {{"Make", "Model"}}]depth = Import["http://exampledata.wolfram.com/bear.heic", "DepthImage"]Combine the depth image with the original image:
image = Import["http://exampledata.wolfram.com/bear.heic", "Image"]ImageMultiply[image, ImageResize[depth, ImageDimensions[image]]]Export (2)
Export an image to a HEIF file:
Export["image.heif", RadialGradientImage[{Red, Green, Blue}, 50]]Import[%]Export list of images to a HEIF file:
Export["image.heif", RadialGradientImage[#, 50]& /@ Permutations[{Red, Green, Blue}]]Import[%]Import Elements (28)
Available Elements (2)
Data Representation (11)
"AnimatedImage" (1)
Import the image sequence as an AnimatedImage:
Import["http://exampledata.wolfram.com/fountain.heic", "AnimatedImage", FrameRate -> 4]"Data" (1)
"DepthImage" (1)
depth = Import["http://exampledata.wolfram.com/bear.heic", "DepthImage"]image = Import["http://exampledata.wolfram.com/bear.heic", "Image"]The depth image and image typically have different dimensions:
ImageDimensions /@ {depth, image}Combine the depth image with the original image:
ImageMultiply[image, ImageResize[depth, ImageDimensions[image]]]"DepthImageFullSize" (1)
Import["http://exampledata.wolfram.com/bear.heic", "DepthImage"]//ImageDimensionsImport the depth image data resized to match the image data dimensions:
Import["http://exampledata.wolfram.com/bear.heic", "DepthImageFullSize"]//ImageDimensionsCompare with dimensions of the image data:
Import["http://exampledata.wolfram.com/bear.heic", "Image"]//ImageDimensions"Graphics" (1)
Import as a Graphics object:
Import["ExampleData/sample.heic", "Graphics"]Head[%]"GraphicsList" (1)
Import the data as a list of Graphics objects:
images = Import["http://exampledata.wolfram.com/fountain.heic", "GraphicsList"];
RandomSample[images, 2]Head /@ %"Image" (1)
Import as an Image object:
Import["ExampleData/sample.heic", "Image"]Head[%]This is the default import element for HEIF:
Import["ExampleData/sample.heic"]"ImageList" (2)
Import the data as a list of Image objects:
images = Import["http://exampledata.wolfram.com/fountain.heic", "ImageList"];
RandomSample[images, 2]This is the default import element for HEIF:
Head /@ Import["http://exampledata.wolfram.com/fountain.heic"]//ShortImport["http://exampledata.wolfram.com/fountain.heic", {"ImageList", Range[3]}]"Thumbnail" (1)
Metadata (15)
"BitDepth" (1)
"CameraTopOrientation" (1)
"Channels" (1)
"ColorSpace" (1)
Get the color encoding used on export:
Import["ExampleData/sample.heic", "ColorSpace"]Use ImageColorSpace to get the color space of an imported image:
Import["ExampleData/sample.heic"]//ImageColorSpace"Exif" (3)
Import["ExampleData/sample.heic", "Exif"]Extract an individual tag from the association:
Import["ExampleData/sample.heic", "Exif"]["Photo", "FNumber"]Individual Exif tags can also be imported directly:
Import["ExampleData/sample.heic", "FNumber"]Some Exif tags are processed to give more detailed information:
Import["ExampleData/sample.heic", "Orientation"]Compare with the raw "Orientation" tag:
Import["ExampleData/sample.heic", "RawExif"]["Image", "Orientation"]"ImageCount" (1)
"MetaInformation" (1)
"RasterSize" (1)
Get the dimensions of the image stored in the file:
Import["ExampleData/sample.heic", "RasterSize"]Using ImageDimensions on an imported image gives the same result:
Import["ExampleData/sample.heic"]//ImageDimensions"RawExif" (1)
Import["ExampleData/sample.heic", "RawExif"]Raw Exif tags return the actual values stored in the file:
Import["ExampleData/sample.heic", "RawExif"]["Photo", "FocalLength"]When importing "Exif", most tags are processed:
Import["ExampleData/sample.heic", "Exif"]["Photo", "FocalLength"]"RawXMP" (1)
"Summary" (1)
"SummarySlideView" (1)
Import Options (5)
ImageResolution (1)
By default, the image resolution is extracted from the file:
Options[Import["ExampleData/sample.heic"], ImageResolution]Specify the resolution of the imported image:
Options[Import["ExampleData/sample.heic", ImageResolution -> 72], ImageResolution]Specify different resolutions in
and
directions:
Options[Import["ExampleData/sample.heic", ImageResolution -> {72, 144}], ImageResolution]"ImageTopOrientation" (1)
By default, images are imported with the native orientation stored in the file:
Import["ExampleData/sample.heic"]Specify the side that is supposed to be on the top:
Import["ExampleData/sample.heic", "ImageTopOrientation" -> Left]The correct orientation can also be achieved by rotating the image to be upright:
ImageRotate[Import["ExampleData/sample.heic"], Left -> Top]IncludeMetaInformation (2)
By default, all available metadata is imported:
Options[Import["ExampleData/sample.heic"], MetaInformation]//ShortPossible classes of metadata for HEIF files are "Exif" and "XMP":
Options[Import["ExampleData/sample.heic"], MetaInformation][[1, 2]]//KeysImport the image with no metadata:
Options[Import["ExampleData/sample.heic", IncludeMetaInformation -> None], MetaInformation]Export Options (4)
CompressionLevel (1)
By default, no compression is used during export:
i = [image];Export["image.heic", i]A larger CompressionLevel can decrease the file size:
Export["image2.heic", i, CompressionLevel -> .9]FileSize /@ {"image.heic", "image2.heic"}Notice the decreased quality of the exported image:
Import["image2.heic"]Compare the change in file size and quality difference using different compression levels:
t = Table[{FileSize[Export["file.heic", i, CompressionLevel -> level]], ImageDistance[Import["file.heic"], i]}, {level, 0, 1, .05}];ListLinePlot[Transpose[t], ...]"ImageTopOrientation" (1)
By default, images are exported with their native orientation:
i = [image];Export["image.heic", i]Import["image.heic", "Orientation"]Specify the side that is supposed to be on the top:
Export["image.heic", i, "ImageTopOrientation" -> Left]Import["image.heic", "Orientation"]IncludeMetaInformation (1)
RasterSize (1)
By default, images are exported in their full resolution:
i = [image];Export["image.heic", i]Import["image.heic", "RasterSize"]Specify the raster size of the imported HEIF image:
Export["image.heic", i, RasterSize -> {20, 20}]Import["image.heic", "RasterSize"]Tech Notes
Related Guides
History
Introduced in 2020 (12.1) | Updated in 2021 (12.3) ▪ 2021 (13.0) ▪ 2022 (13.1) ▪ 2022 (13.2) ▪ 2026 (15.0)