HeifFile object¶
The HeifFile provide all necessary methods for HEIF image manipulations.
- class pillow_heif.HeifFile(fp=None, convert_hdr_to_8bit=True, bgr_mode=False, **kwargs)[source]¶
- Representation of the - HeifImageclasses container.- To create - HeifFileobject, use the appropriate factory functions.- Exceptions that can be raised when working with methods:
- ValueError, EOFError, SyntaxError, RuntimeError, OSError 
 - property size¶
- sizeproperty of the primary- HeifImage.- Raises:
- IndexError – If there are no images. 
 
 - property mode¶
- modeproperty of the primary- HeifImage.- Raises:
- IndexError – If there are no images. 
 
 - property has_alpha¶
- has_alphaproperty of the primary- HeifImage.- Raises:
- IndexError – If there are no images. 
 
 - property premultiplied_alpha¶
- premultiplied_alphaproperty of the primary- HeifImage.- Raises:
- IndexError – If there are no images. 
 
 - property data¶
- dataproperty of the primary- HeifImage.- Raises:
- IndexError – If there are no images. 
 
 - property stride¶
- strideproperty of the primary- HeifImage.- Raises:
- IndexError – If there are no images. 
 
 - property info¶
- info` dict of the primary - HeifImagein the container.- Raises:
- IndexError – If there are no images. 
 
 - to_pillow() Image[source]¶
- Helper method to create Pillow - Image.- Returns:
- Imageclass created from the primary image.
 
 - save(fp, **kwargs) None[source]¶
- Saves image(s) under the given fp. - Keyword options can be used to provide additional instructions to the writer. If a writer does not recognize an option, it is silently ignored. - Supported options:
- save_all- boolean. Should all images from- HeiFilebe saved? (default =- True)- append_images- do the same as in Pillow. Accepts the list of- HeifImage- Note - Appended images always will have - info["primary"]=False- quality- see- QUALITY- enc_params- dictionary with key:value to pass to x265 encoder.- exif- override primary image’s EXIF with specified. Accepts- None,- bytesor- PIL.Image.Exifclass.- xmp- override primary image’s XMP with specified. Accepts- Noneor- bytes.- primary_index- ignore- info["primary"]and set PrimaryImage by index.- chroma- custom subsampling value. Possible values:- 444,- 422or- 420(- x265default).- subsampling- synonym for chroma. Format is string, compatible with Pillow:- x:x:x, e.g. ‘4:4:4’.- save_nclx_profile- boolean, see- SAVE_NCLX_PROFILE- matrix_coefficients- int, nclx profile: color conversion matrix coefficients, default=6 (see h.273)- color_primaries- int, nclx profile: color primaries (see h.273)- transfer_characteristic- int, nclx profile: transfer characteristics (see h.273)- full_range_flag- nclx profile: full range flag, default: 1
 - Parameters:
- fp – A filename (string), pathlib.Path object or an object with write method. 
 
 - add_frombytes(mode: str, size: tuple[int, int], data, **kwargs)[source]¶
- Adds image from bytes to container. - Note - Supports - stridevalue if needed.
 - get_aux_image(aux_id)[source]¶
- get_aux_image` method of the primary - HeifImagein the container.- Raises:
- IndexError – If there are no images.