Skip to content

Commit

Permalink
v0.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
bigcat88 committed Jun 16, 2022
1 parent 5f9cb99 commit c089d1e
Show file tree
Hide file tree
Showing 2 changed files with 300 additions and 870 deletions.
9 changes: 2 additions & 7 deletions pillow_heif/heif.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ def __init__(self, img_id: int, heif_ctx: Union[LibHeifCtx, HeifCtxAsDict], prim
additional_info.update(heif_ctx.additional_info)
super().__init__(heif_ctx, handle)
self.info = {
"img_id": img_id,
"exif": _exif,
"xmp": _xmp,
"primary": primary,
Expand All @@ -280,8 +279,7 @@ def __repr__(self):
_bytes = f"{len(self.data)} bytes" if self._img_data else "no"
return (
f"<{self.__class__.__name__} {self.size[0]}x{self.size[1]} {self.mode} "
f"with id = {self.info['img_id']}, {len(self.thumbnails)} thumbnails. "
f"{_bytes} image data>"
f"with {_bytes} image data and {len(self.thumbnails)} thumbnails>"
)

def load(self):
Expand Down Expand Up @@ -602,7 +600,6 @@ def add_from_heif(self, heif_image, load_one=False, ignore_primary=True, **kwarg
heif_images = [heif_image]
for image in heif_images:
additional_info = image.info.copy()
additional_info.pop("img_id", None)
if ignore_primary:
additional_info["primary"] = False
added_image = self._add_frombytes(
Expand Down Expand Up @@ -708,10 +705,8 @@ def __delitem__(self, key):
del self.images[key]

def _add_frombytes(self, bit_depth: int, mode: str, size: tuple, data, **kwargs):
__ids = [i.info["img_id"] for i in self.images] + [0]
__new_id = 2 + max(__ids)
__heif_ctx = HeifCtxAsDict(bit_depth, mode, size, data, **kwargs)
added_image = HeifImage(__new_id, __heif_ctx)
added_image = HeifImage(0, __heif_ctx)
self.images.append(added_image)
return added_image

Expand Down
Loading

0 comments on commit c089d1e

Please sign in to comment.