HeifImage object
- class pillow_heif.HeifImage(c_image)[source]
Bases:
BaseImageOne image in a
HeifFilecontainer.- info["exif"]: bytes
Note
In HEIF orientation tag is only for information purposes and must not be used to rotate image.
EXIF metadata. Can be None
- info["xmp"]: bytes
XMP metadata. String in bytes in UTF-8 encoding. Absent if xmp data is missing.
- info["metadata"]: list[dict]
Other metadata(IPTC for example). List of dictionaries. Usual will be empty. Keys:
type: str
content_type: str
data: bytes
- info["primary"]: bool
A boolean value that specifies whether the image is the main image when the file contains more than one image.
- info["bit_depth"]: int
Shows the bit-depth of image in file(not the decoded one, so it may differs from bit depth of mode). Possible values: 8, 10 and 12.
- info["chroma"]: int
Chroma subsampling of the image in file. Possible values: 420, 422 and 444. Absent for monochrome images.
- info["thumbnails"]: list[int]
List of thumbnail boxes sizes. Can be empty.
- info["icc_profile"]: bytes
ICC Profile. Can be absent. Can be empty.
- info["icc_profile_type"]: str
Possible values:
proforrICC. Can be absent.
- info["nclx_profile"]: dict
NCLX color profile. Can be absent. Keys:
color_primaries:
HeifColorPrimariestransfer_characteristics:
HeifTransferCharacteristicsmatrix_coefficients:
HeifMatrixCoefficientsfull_range_flag: bool
- info["content_light_level"]: dict
Content light level information(
clli). Can be absent. Keys:max_content_light_level: int
max_pic_average_light_level: int
- info["mastering_display_colour_volume"]: dict
Mastering display colour volume(
mdcv). Can be absent. Keys:display_primaries_x: tuple[int, int, int]
display_primaries_y: tuple[int, int, int]
white_point_x: int
white_point_y: int
max_display_mastering_luminance: int
min_display_mastering_luminance: int
- info["ambient_viewing_environment"]: dict
Ambient viewing environment(
amve). Can be absent. Keys:ambient_illumination: int
ambient_light_x: int
ambient_light_y: int
Note
These three properties hold the raw code values as defined in ITU-T H.274. Like
nclx_profileandicc_profilethey are written back during save; remove a key frominfoif you do not want it in the output file.
- info["pixel_aspect_ratio"]: tuple[int, int]
Pixel aspect ratio(
pasp) as(horizontal_spacing, vertical_spacing). Absent when the image has nopaspbox. It is written back during save.
- info["depth_images"]: list
List of
HeifDepthImageif any present for image. Currently libheif does not support writing of them, only reading.
- info["aux"]: dict
Auxiliary images present for the image. Keys are the auxiliary types, e.g.
urn:com:apple:photo:2020:aux:hdrgainmap, values are lists of IDs to pass toget_aux_image(). Empty when the image has no auxiliary images. Currently libheif does not support writing of them, only reading.
- info["tiling"]: dict
Tiling information when the image is stored as a grid of tiles. Absent for non-tiled images. All values are in the display space, the same as
size. Keys:num_columns: int
num_rows: int
tile_width: int
tile_height: int
image_width: int
image_height: int
- info["heif"]: dict
Camera matrices of the image, present only when the file contains them. Keys:
camera_intrinsic_matrix: dict with focal_length_x, focal_length_y, principal_point_x, principal_point_y and skew
camera_extrinsic_matrix_rot: tuple of nine float, the rotation matrix
Note
These values are currently not written back during save.
- property premultiplied_alpha: bool
Truefor images withpremultiplied alphachannel,Falseotherwise.
- to_pillow() Image[source]
Helper method to create
Imageclass.- Returns:
Imageclass created from an image.
- get_aux_image(aux_id: int) HeifAuxImage[source]
Method to retrieve the auxiliary image at the given ID.
- Returns:
a
HeifAuxImageclass instance.
- property data
Decodes image and returns image data.
- Returns:
bytesof the decoded image.
- load() None
Method to decode image.
Note
In normal cases, you should not call this method directly, when reading data or stride property of image will be loaded automatically.
- property stride: int
Stride of the image.
Note
from 0.10.0 version this value always will have width * sizeof pixel in default usage mode.
- Returns:
An Int value indicating the image stride after decoding.
- mode: str
A string which defines the type and depth of a pixel in the image: Pillow Modes
For currently supported modes by Pillow-Heif see Modes.
- class pillow_heif.heif.BaseImage(c_image)[source]
Bases:
objectBase class for
HeifImage,HeifDepthImageandHeifAuxImage.- mode: str
A string which defines the type and depth of a pixel in the image: Pillow Modes
For currently supported modes by Pillow-Heif see Modes.
- property data
Decodes image and returns image data.
- Returns:
bytesof the decoded image.
- property stride: int
Stride of the image.
Note
from 0.10.0 version this value always will have width * sizeof pixel in default usage mode.
- Returns:
An Int value indicating the image stride after decoding.
- class pillow_heif.heif.HeifDepthImage(c_image)[source]
Bases:
BaseImageClass representing the depth image associated with the
HeifImageclass.- info["metadata"]: dict
Represents libheif
heif_depth_representation_infostruct as a dictionary.If someone have an example when this struct got filled let me know.
- to_pillow() Image[source]
Helper method to create
Imageclass.- Returns:
Imageclass created from an image.
- property data
Decodes image and returns image data.
- Returns:
bytesof the decoded image.
- load() None
Method to decode image.
Note
In normal cases, you should not call this method directly, when reading data or stride property of image will be loaded automatically.
- property stride: int
Stride of the image.
Note
from 0.10.0 version this value always will have width * sizeof pixel in default usage mode.
- Returns:
An Int value indicating the image stride after decoding.
- mode: str
A string which defines the type and depth of a pixel in the image: Pillow Modes
For currently supported modes by Pillow-Heif see Modes.
- class pillow_heif.heif.HeifAuxImage(c_image)[source]
Bases:
BaseImageClass representing the auxiliary image associated with the
HeifImageclass.- property data
Decodes image and returns image data.
- Returns:
bytesof the decoded image.
- load() None
Method to decode image.
Note
In normal cases, you should not call this method directly, when reading data or stride property of image will be loaded automatically.
- property stride: int
Stride of the image.
Note
from 0.10.0 version this value always will have width * sizeof pixel in default usage mode.
- Returns:
An Int value indicating the image stride after decoding.
- mode: str
A string which defines the type and depth of a pixel in the image: Pillow Modes
For currently supported modes by Pillow-Heif see Modes.