HeifImage object — pillow-heif 0.22.0 documentation

# HeifImage object

class pillow_heif.HeifImage(c_image)

  Bases: `BaseImage`

  One image in a `HeifFile` container.

  info[]: 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[]: bytes

    XMP metadata. String in bytes in UTF-8 encoding. Absent if xmp data is missing.

  info[]: list[dict]

    Other metadata(IPTC for example). List of dictionaries. Usual will be empty. Keys:

    > - type: str

    > - content_type: str

    > - data: bytes

  info[]: bool

    A boolean value that specifies whether the image is the main image when the file contains more than one image.

  info[]: 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[]: list[int]

    List of thumbnail boxes sizes. Can be empty.

  info[]: bytes

    ICC Profile. Can be absent. Can be empty.

  info[]: str

    Possible values: `prof` or `rICC`. Can be absent.

  info[]: dict

    NCLX color profile. Can be absent. Keys:

    > - color_primaries: `HeifColorPrimaries`

    > - transfer_characteristics: `HeifTransferCharacteristics`

    > - matrix_coefficients: `HeifMatrixCoefficients`

    > - full_range_flag: bool

  info[]: list

    List of `HeifDepthImage` if any present for image. Currently libheif does not support writing of them, only reading.

  property has_alpha: bool

    `True` for images with the `alpha` channel, `False` otherwise.

  property premultiplied_alpha: bool

    `True` for images with `premultiplied alpha` channel, `False` otherwise.

  to_pillow() → Image

    Helper method to create `Image` class.

    Returns:

      `Image` class created from an image.

  get_aux_image(aux_id: int) → HeifAuxImage

    Method to retrieve the auxiliary image at the given ID.

    Returns:

      a `HeifAuxImage` class instance.

  property data

    Decodes image and returns image data.

    Returns:

      `bytes` of 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.

  size: tuple[int, int]

    Width and height of the image.

  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)

  Bases: `object`

  Base class for `HeifImage`, `HeifDepthImage` and `HeifAuxImage`.

  size: tuple[int, int]

    Width and height of the image.

  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:

      `bytes` of 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.

  to_pillow() → Image

    Helper method to create `Image` class.

    Returns:

      `Image` class created from an 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.

class pillow_heif.heif.HeifDepthImage(c_image)

  Bases: `BaseImage`

  Class representing the depth image associated with the `HeifImage` class.

  info[]: dict

    Represents libheif `heif_depth_representation_info` struct as a dictionary.

    If someone have an example when this struct got filled let me know.

  to_pillow() → Image

    Helper method to create `Image` class.

    Returns:

      `Image` class created from an image.

  property data

    Decodes image and returns image data.

    Returns:

      `bytes` of 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.

  size: tuple[int, int]

    Width and height of the image.

  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.