Check for portrait effects matte metadata in existing images.
The portrait effects matte is stored in the image file alongside the depth data auxiliary image. You can load, view, and edit the portrait effects matte as a high-level object called an
AVPortrait, analogous to
AVDepth. This mirrors traditional depth map access using
AVDepth in its technique to get the elementary auxiliary image bits out of the file.
Load and View a Matting Image from File
Load the portrait effects matte by using the Image IO Framework to extract an auxiliary image of type
k. Convert this auxiliary image to an auxiliary information dictionary, which contains the matte as metadata of class
CGImage. Generate the portrait effects matte object,
AVPortrait, by passing the dictionary to
portrait. From this object, you can generate a
CIImage object to bring the image into viewable forms, like
With this matte image, your app can:
Access the uncompressed pixels of the portrait effects matte in memory.
Create rotated or flipped derivative copies of the mask.
Replace a pixel of the matte with one of your own, reflecting an effect you're applying to the main image.
Create a dictionary of elementary PEM parts suitable for writing to a file using Image I/O’s
When decompressed, the matte images are natively L008 (
k), which is an 8-bit one-component format where black is zero. Portrait effects matte images are not gamma corrected. They're tagged with a linear transfer function, indicating that no color correction should be applied when working with them.