Skip to content

Commit d8b34e2

Browse files
author
bstorm
committed
some fixes on pnm type selections
1 parent aa1bc7c commit d8b34e2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

adafruit_imageload/pnm/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def load(f, header, *, bitmap=None, palette=None):
6363
if next_byte != b"\n":
6464
break
6565
if next_byte.isdigit():
66-
pnm_header.append(next_byte)
66+
pnm_header.append(int.from_bytes(next_byte, "big"))
6767
continue
6868

6969
if not next_byte:
@@ -75,11 +75,12 @@ def load(f, header, *, bitmap=None, palette=None):
7575
return pgm.load(
7676
f, magic_number, pnm_header, bitmap=bitmap, palette=palette
7777
)
78-
elif magic_number.startswith(b"P3") or magic_number.startswith(b"P6"):
78+
79+
if magic_number.startswith(b"P3") or magic_number.startswith(b"P6"):
7980
from . import ppm
8081

8182
return ppm.load(
8283
f, magic_number, pnm_header, bitmap=bitmap, palette=palette
8384
)
84-
else:
85-
raise RuntimeError("Unsupported image format")
85+
86+
raise RuntimeError("Unsupported image format")

0 commit comments

Comments
 (0)