Asynchronous API¶
Asynchronous wrappers enabling non-blocking execution inside asyncio event loops.
AsyncHeifContext¶
pylibheif.AsyncHeifContext ¶
Async wrapper for HeifContext with custom executor and async factory support.
__doc__
class-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__module__
class-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
max_decoding_threads
property
¶
Maximum background threads used for parallel tile decoding.
add_compatible_brand ¶
Add a compatible brand to the HEIF container (4-character FourCC).
add_visual_sequence_track ¶
add_visual_sequence_track(width: int, height: int, track_type: Union[HeifTrackType, int] = ImageSequence, timescale: int = 1000) -> AsyncHeifTrack
Add a visual sequence track to the context for encoding.
add_visual_sequence_track_async ¶
add_visual_sequence_track_async(width: int, height: int, track_type: Union[HeifTrackType, int] = ImageSequence, timescale: int = 1000) -> AsyncHeifTrack
Asynchronously add a visual sequence track.
from_file
classmethod
¶
Async factory method to construct and read context from file.
from_memory
classmethod
¶
from_memory(data: Union[bytes, bytearray, memoryview], executor: Optional[Executor] = None) -> AsyncHeifContext
Async factory method to construct and read context from memory bytes.
from_stream
classmethod
¶
Async factory method to construct and read context from a Python stream.
get_image_handle ¶
Get async wrapper for specific image ID.
get_image_handle_async ¶
Asynchronously get image handle for specific image ID.
get_max_decoding_threads ¶
Asynchronously get maximum background threads used for parallel tile decoding.
get_number_of_sequence_tracks ¶
Get the number of sequence tracks.
get_primary_image_handle ¶
Get async wrapper for primary image handle.
get_primary_image_handle_async ¶
Asynchronously get primary image handle.
get_sequence_timescale ¶
Get the sequence timescale (ticks per second).
get_track ¶
Get a track wrapper (use track_id=0 for first visual track).
get_track_async ¶
Asynchronously get a track wrapper.
read_from_memory ¶
Asynchronously read from memory.
read_from_stream ¶
Asynchronously read from a Python file-like stream object.
set_major_brand ¶
Set the major brand of the HEIF container (4-character FourCC).
set_max_decoding_threads ¶
Asynchronously set maximum background threads for parallel tile decoding.
set_number_of_sequence_repetitions ¶
Set the repetition count for the sequence (0 = infinite).
set_primary_image ¶
Designate an image handle as the primary image of the context.
set_primary_image_async ¶
Asynchronously designate an image handle as the primary image of the context.
set_sequence_timescale ¶
Set the sequence timescale (ticks per second).
write_to_bytes ¶
Asynchronously export context to Python bytes (copy=True) or zero-copy memoryview (copy=False).
write_to_memoryview ¶
Asynchronously export context directly to a zero-copy Python memoryview.
write_to_stream ¶
Asynchronously write to a Python file-like stream object.
AsyncHeifImageHandle¶
pylibheif.AsyncHeifImageHandle ¶
Async wrapper for HeifImageHandle.
__doc__
class-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__module__
class-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
depth_map
property
¶
Asynchronous DepthMap domain entity, or None if no depth image exists.
portrait_matte
property
¶
Apple Portrait Matte (foreground segmentation alpha mask), or None.
decode ¶
decode(colorspace: HeifColorspace = RGB, chroma: HeifChroma = InterleavedRGB, options: Optional[HeifDecodingOptions] = None, num_threads: Optional[int] = None, target_colorspace: Optional[Union[str, bytes]] = None, intent: Union[RenderingIntent, int, str] = <RenderingIntent.PERCEPTUAL: 0>, bpc: bool = True, prefer_nclx: bool = False) -> HeifImage
Asynchronously decode the image with optional color space conversion.
AsyncHeifEncoder¶
pylibheif.AsyncHeifEncoder ¶
Async wrapper for HeifEncoder.
__doc__
class-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__module__
class-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
encode_image ¶
encode_image(context: Union[HeifContext, AsyncHeifContext], image: HeifImage, preset: str = '', options: Optional[HeifEncodingOptions] = None) -> HeifImageHandle
Asynchronously encode image.
encode_thumbnail ¶
encode_thumbnail(context: Union[HeifContext, AsyncHeifContext], image: HeifImage, master_image: Union[HeifImageHandle, AsyncHeifImageHandle], bbox_size: int, options: Optional[HeifEncodingOptions] = None) -> Optional[HeifImageHandle]
Asynchronously encode thumbnail image.
AsyncHeifTrack¶
pylibheif.AsyncHeifTrack ¶
Async wrapper for HeifTrack (timed image sequences/animations).
__doc__
class-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__module__
class-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
decode_next_image ¶
decode_next_image(colorspace: HeifColorspace = RGB, chroma: HeifChroma = InterleavedRGB, options: Optional[HeifDecodingOptions] = None) -> Optional[HeifImage]
Decode next image frame in sequence. Returns None at end of sequence.
decode_next_image_async ¶
decode_next_image_async(colorspace: HeifColorspace = RGB, chroma: HeifChroma = InterleavedRGB, options: Optional[HeifDecodingOptions] = None) -> Optional[HeifImage]
Asynchronously decode next image frame in sequence.
encode_end_of_sequence ¶
Finalize the sequence track encoding.
encode_end_of_sequence_async ¶
Asynchronously finalize the sequence track encoding.
encode_sequence_image ¶
encode_sequence_image(image: HeifImage, encoder: Union[HeifEncoder, AsyncHeifEncoder], save_alpha: bool = False) -> None
Append a frame to the sequence track.
encode_sequence_image_async ¶
encode_sequence_image_async(image: HeifImage, encoder: Union[HeifEncoder, AsyncHeifEncoder], save_alpha: bool = False) -> None
Asynchronously append a frame to the sequence track.
rewind_async ¶
Asynchronously rewind sequence track playback back to frame 0.