Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/PIL/PcxImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _open(self) -> None:
# header
assert self.fp is not None

s = self.fp.read(128)
s = self.fp.read(68)
if not _accept(s):
msg = "not a PCX file"
raise SyntaxError(msg)
Expand All @@ -66,6 +66,8 @@ def _open(self) -> None:
raise SyntaxError(msg)
logger.debug("BBox: %s %s %s %s", *bbox)

offset = self.fp.tell() + 60

# format
version = s[1]
bits = s[3]
Expand Down Expand Up @@ -102,7 +104,6 @@ def _open(self) -> None:
break
if mode == "P":
self.palette = ImagePalette.raw("RGB", s[1:])
self.fp.seek(128)

elif version == 5 and bits == 8 and planes == 3:
mode = "RGB"
Expand All @@ -128,9 +129,7 @@ def _open(self) -> None:
bbox = (0, 0) + self.size
logger.debug("size: %sx%s", *self.size)

self.tile = [
ImageFile._Tile("pcx", bbox, self.fp.tell(), (rawmode, planes * stride))
]
self.tile = [ImageFile._Tile("pcx", bbox, offset, (rawmode, planes * stride))]


# --------------------------------------------------------------------
Expand Down
Loading