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,}].
  • 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:
  • imagean Image expression
    graphicsrasterized graphics
    expran 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:
  • Importimport from a file
    CloudImportimport from a cloud object
    ImportStringimport from a string
    ImportByteArrayimport 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

Examples

open allclose all

Basic Examples  (3)

Import a HEIF image as an image:

Summary of an image:

Export an image to a HEIF file:

Scope  (6)

Import  (4)

Import the image as graphics:

Import the image size:

Import metadata elements:

Import depth image:

Plot the depth map with image used as a texture:

Export  (2)

Export an image to a HEIF file:

Export list of images to a HEIF file:

Import Elements  (25)

Available Elements  (2)

List of available elements:

Get image-related information as a list of rules:

Data Representation  (11)

"AnimatedImage"  (1)

Import the image sequence as an AnimatedImage:

"Data"  (1)

Import the image data:

Create an image from imported data:

"DepthImage"  (1)

Import the depth image data:

Import the image data:

The depth image and image typically have different dimensions:

Combine the depth image with the original image:

"DepthImageFullSize"  (1)

Import the depth image data:

Import the depth image data resized to match the image data dimensions:

Compare with dimensions of the image data:

"Graphics"  (1)

Import as a Graphics object:

"GraphicsList"  (1)

Import the data as a list of Graphics objects:

"Image"  (1)

Import as an Image object:

This is the default import element for HEIF:

"ImageList"  (2)

Import the data as a list of Image objects:

This is the default import element for HEIF:

Specify the frames to import:

"Thumbnail"  (1)

Import a thumbnail of an image:

"ThumbnailList"  (1)

Import thumbnails of all the frames in an image:

Metadata  (12)

"BitDepth"  (1)

Get the bit count for the representation of each color channel:

"Channels"  (1)

Get the number of image channels:

"ColorSpace"  (1)

Get the color encoding used on export:

Use ImageColorSpace to get the color space of an imported image:

"Exif"  (3)

Get Exif metadata:

Extract an individual tag from the association:

Individual Exif tags can also be imported directly:

Some Exif tags are processed to give more detailed information:

Compare with the raw "Orientation" tag:

"ImageCount"  (1)

Get the number of frames stored in the file:

"MetaInformation"  (1)

Get all the metainformation:

"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 raw Exif data:

Raw Exif tags return the actual values stored in the file:

When importing "Exif", most tags are processed:

"Summary"  (1)

Get the image summary:

"SummarySlideView"  (1)

Get the image frames' summary:

Import Options  (4)

"ImageTopOrientation"  (1)

By default, images are imported with the native orientation stored in the file:

Specify the side that is supposed to be on the top:

The correct orientation can also be achieved by rotating the image to be upright:

IncludeMetaInformation  (2)

By default, all available metadata is imported:

Possible classes of metadata for HEIF files are "Exif", "IPTC" and "XMP":

Import the image with no metadata:

RasterSize  (1)

By default, images are imported in their full resolution:

Specify the raster size of the imported HEIF image:

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:

IncludeMetaInformation  (1)

By default, all available metadata is exported:

RasterSize  (1)

By default, images are exported in their full resolution:

Specify the raster size of the imported HEIF image: