@@ -93,7 +93,7 @@ def has_alpha(self):
9393 def mode (self ):
9494 """Returns “L“ for Greyscale images, “RGBA” for images with alpha channel and “RGB” for other cases.
9595
96- .. note:: Images with "L" mode currently only possible to get when adding from Pillow.
96+ .. note:: Images with "L" mode currently only possible to get from Pillow.
9797
9898 :returns: "RGB", "RGBA" or "L" """
9999
@@ -249,7 +249,7 @@ def clone_no_data(self):
249249class HeifImage (HeifImageBase ):
250250 """Class represents one frame in a file."""
251251
252- def __init__ (self , img_id : int , heif_ctx : Union [LibHeifCtx , HeifCtxAsDict ], primary = False ):
252+ def __init__ (self , heif_ctx : Union [LibHeifCtx , HeifCtxAsDict ], img_id = - 1 , primary = False ):
253253 additional_info = {}
254254 if isinstance (heif_ctx , LibHeifCtx ):
255255 p_handle = ffi .new ("struct heif_image_handle **" )
@@ -368,7 +368,7 @@ def add_thumbnails(self, boxes: Union[List[int], int]) -> None:
368368 def copy_thumbnails (self , thumbnails : List [HeifThumbnail ], ** kwargs ):
369369 """Private. For use only in ``add_from_pillow`` and ``add_from_heif``."""
370370 for thumb in thumbnails :
371- if kwargs .get ("thumbs_no_data " , False ):
371+ if kwargs .get ("for_encoding " , False ):
372372 cloned_thumb = thumb .clone_no_data ()
373373 else :
374374 cloned_thumb = thumb .clone (ref_original = self )
@@ -407,7 +407,7 @@ def __init__(
407407 self .mimetype = heif_ctx .get_mimetype () if isinstance (heif_ctx , LibHeifCtx ) else ""
408408 if img_ids :
409409 for img_id in img_ids :
410- self .images .append (HeifImage (img_id , heif_ctx , img_id == main_id ))
410+ self .images .append (HeifImage (heif_ctx , img_id , img_id == main_id ))
411411
412412 @property
413413 def original_bit_depth (self ):
@@ -711,7 +711,7 @@ def __delitem__(self, key):
711711
712712 def _add_frombytes (self , bit_depth : int , mode : str , size : tuple , data , ** kwargs ):
713713 __heif_ctx = HeifCtxAsDict (bit_depth , mode , size , data , ** kwargs )
714- added_image = HeifImage (0 , __heif_ctx )
714+ added_image = HeifImage (__heif_ctx )
715715 self .images .append (added_image )
716716 return added_image
717717
@@ -765,10 +765,10 @@ def __get_images_for_save(images: List[HeifImage], **kwargs) -> List[HeifImage]:
765765 result = []
766766 for img in images_to_save :
767767 if isinstance (img , Image .Image ):
768- heif_file = HeifFile ().add_from_pillow (img , save_one , thumbs_no_data = True )
768+ heif_file = HeifFile ().add_from_pillow (img , save_one , for_encoding = True )
769769 else :
770770 no_primary = not bool (img in images )
771- heif_file = HeifFile ().add_from_heif (img , save_one , no_primary , thumbs_no_data = True )
771+ heif_file = HeifFile ().add_from_heif (img , save_one , no_primary , for_encoding = True )
772772 result += list (heif_file )
773773 return result
774774
0 commit comments