Skip to content

Commit 7144557

Browse files
authored
Resolves #44 (#46)
1 parent 0430fcb commit 7144557

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

pillow_heif/misc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ def set_orientation(info: dict, orientation: int = 1) -> Union[int, None]:
3434

3535
original_orientation = None
3636
if info.get("exif", None):
37-
tif_tag = info["exif"][6:]
37+
tif_tag = info["exif"]
38+
if tif_tag.startswith(b"Exif\x00\x00"):
39+
tif_tag = tif_tag[6:]
3840
endian_mark = "<" if tif_tag[0:2] == b"\x49\x49" else ">"
3941
pointer = unpack(endian_mark + "L", tif_tag[4:8])[0]
4042
tag_count = unpack(endian_mark + "H", tif_tag[pointer : pointer + 2])[0]

pillow_heif/private.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def retrieve_exif(metadata: list):
159159
for i, md_block in enumerate(metadata):
160160
if md_block["type"] == "Exif":
161161
_purge.append(i)
162-
if not _result and md_block["data"] and md_block["data"][0:4] == b"Exif":
162+
if not _result and md_block["data"]:
163163
_result = md_block["data"]
164164
for i in reversed(_purge):
165165
del metadata[i]

0 commit comments

Comments
 (0)