[docs]defauto_image_class()->ImageMeta:"""Selects the image render style that best suits the current terminal emulator. Returns: An image class (a subclass of :py:class:`BaseImage`). """forclsin_styles:ifcls.is_supported():breakreturncls
[docs]defAutoImage(image:PIL.Image.Image,*,width:Optional[int]=None,height:Optional[int]=None,)->BaseImage:"""Creates an image instance from a PIL image instance. Returns: An instance of the automatically selected image render style (as returned by :py:func:`auto_image_class`). Same arguments and raised exceptions as the :py:class:`BaseImage` class constructor. """returnauto_image_class()(image,width=width,height=height)
[docs]deffrom_file(filepath:Union[str,os.PathLike],**kwargs:Union[None,int],)->BaseImage:"""Creates an image instance from an image file. Returns: An instance of the automatically selected image render style (as returned by :py:func:`auto_image_class`). Same arguments and raised exceptions as :py:meth:`BaseImage.from_file`. """returnauto_image_class().from_file(filepath,**kwargs)
[docs]deffrom_url(url:str,**kwargs:Union[None,int],)->BaseImage:"""Creates an image instance from an image URL. Returns: An instance of the automatically selected image render style (as returned by :py:func:`auto_image_class`). Same arguments and raised exceptions as :py:meth:`BaseImage.from_url`. """returnauto_image_class().from_url(url,**kwargs)
# In order of preference, based on image quality and style performance/functionality_styles=(KittyImage,ITerm2Image,BlockImage)