HEIF (.heic, .heif)
- Import and Export fully support the HEIF standard on macOS and have limitations on Windows.
- Import and Export also support Exif 2.3 and IPTC 4.2 metadata standards.
- HEIF is not supported on Linux.
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,…}].
- On macOS, HEIF is fully supported.
- On Windows, the HEVC codec should be manually installed, which will still provide more limited import capabilities compared to macOS.
- On Linux, HEIF import and export is not supported.
- 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.
- Exporting to HEIF is only supported on macOS.
- 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 - On windows, multiframe HEIF files are always imported as a single frame image and no depth information can be imported.
- Import by default uses the "Image" element for the HEIF format.
- 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) "IPTC" formatted IPTC (International Press Telecommunications Council) "MetaInformation" combination of all formatted metadata present in the file - Raw metadata, as stored in the file, can be imported using "RawExif" and "RawIPTC", which is returned as an association.
- All Exif and IPTC 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 - On Windows, some metadata elements such as orientation may be missing.
Options
- Import and Export options:
-
IncludeMetaInformation All whether to import metadata "ImageTopOrientation" Automatic orientation of the image as stored in the file RasterSize Automatic dimensions of the image - Export option:
-
CompressionLevel 0 compression level, given as a number between 0 and 1 - Export options for animated HEIFs:
-
"RemoveDuplicatedFrames" False whether to remove duplicated frames
Examples
open allclose allBasic Examples (3)
Scope (6)
Import Elements (25)
Available Elements (2)
Data Representation (11)
"AnimatedImage" (1)
Import the image sequence as an AnimatedImage:
"DepthImage" (1)
"DepthImageFullSize" (1)
"Graphics" (1)
Import as a Graphics object:
"GraphicsList" (1)
Import the data as a list of Graphics objects:
"Image" (1)
"ImageList" (2)
Import the data as a list of Image objects:
Metadata (12)
"ColorSpace" (1)
Get the color encoding used on export:
Use ImageColorSpace to get the color space of an imported image:
"Exif" (3)
"RasterSize" (1)
Get the dimensions of the image stored in the file:
Using ImageDimensions on an imported image gives the same result:
"RawExif" (1)
Import Options (4)
"ImageTopOrientation" (1)
IncludeMetaInformation (2)
Export Options (3)
CompressionLevel (1)
By default, no compression is used during export:
A larger CompressionLevel can decrease the file size:
Notice the decreased quality of the exported image:
Compare the change in file size and quality difference using different compression levels: