Skip to content

Commit a839c84

Browse files
committed
cleanup: removing unused old code
1 parent 374283d commit a839c84

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

pillow_heif/heif.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Functions and classes for heif images to read and write.
33
"""
44

5-
from typing import Any, Dict, Iterator, List, Union
5+
from typing import Any, Dict, Iterator, List, Optional, Union
66
from weakref import ref
77

88
from _pillow_heif_cffi import ffi, lib
@@ -388,15 +388,13 @@ class HeifFile:
388388
389389
.. note:: To get an empty container to fill up later, create a class with no parameters."""
390390

391-
def __init__(
392-
self, heif_ctx: Union[LibHeifCtx, HeifCtxAsDict] = None, img_ids: List[int] = None, main_id: int = None
393-
):
394-
if heif_ctx is None:
395-
heif_ctx = HeifCtxAsDict("", (0, 0), None)
391+
def __init__(self, heif_ctx: Optional[LibHeifCtx] = None):
392+
self.mimetype = ""
396393
self.images: List[HeifImage] = []
397-
self.mimetype = heif_ctx.mimetype if isinstance(heif_ctx, LibHeifCtx) else ""
398-
if img_ids:
399-
for img_id in img_ids:
394+
if isinstance(heif_ctx, LibHeifCtx):
395+
self.mimetype = heif_ctx.mimetype
396+
main_id = heif_ctx.get_main_img_id()
397+
for img_id in heif_ctx.get_top_images_ids():
400398
self.images.append(HeifImage(heif_ctx, img_id, img_id == main_id))
401399

402400
@property
@@ -816,8 +814,7 @@ def open_heif(fp, convert_hdr_to_8bit=True) -> HeifFile:
816814
:returns: An :py:class:`~pillow_heif.HeifFile` object.
817815
:exception HeifError: If file is corrupted or is not in Heif format."""
818816

819-
heif_ctx = LibHeifCtx(fp, convert_hdr_to_8bit)
820-
return HeifFile(heif_ctx, heif_ctx.get_top_images_ids(), heif_ctx.get_main_img_id())
817+
return HeifFile(LibHeifCtx(fp, convert_hdr_to_8bit))
821818

822819

823820
def read_heif(fp, convert_hdr_to_8bit=True) -> HeifFile:
@@ -833,9 +830,7 @@ def read_heif(fp, convert_hdr_to_8bit=True) -> HeifFile:
833830
:returns: An :py:class:`~pillow_heif.HeifFile` object.
834831
:exception HeifError: If file is corrupted or is not in Heif format."""
835832

836-
heif_file = open_heif(fp, convert_hdr_to_8bit)
837-
heif_file.load(everything=True)
838-
return heif_file
833+
return open_heif(fp, convert_hdr_to_8bit).load(everything=True)
839834

840835

841836
def from_pillow(pil_image: Image.Image, load_one: bool = False, ignore_primary=True) -> HeifFile:

0 commit comments

Comments
 (0)