Skip to content

Commit

Permalink
add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Yay295 committed Sep 3, 2024
1 parent 42c7678 commit 14e4961
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/PIL/EpsImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,11 @@ def read_comment(s: str) -> bool:
# Check for an "ImageData" descriptor
# https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577413_pgfId-1035096

# If we've already read an "ImageData" descriptor, don't read another one.
if imagedata_size:
bytes_read = 0
continue

# Values:
# columns
# rows
Expand All @@ -320,10 +325,6 @@ def read_comment(s: str) -> bool:
# binary/ascii (1: binary, 2: ascii)
# data start identifier (the image data follows after a single line
# consisting only of this quoted value)
if imagedata_size:
bytes_read = 0
continue

image_data_values = byte_arr[11:bytes_read].split(None, 7)
columns, rows, bit_depth, mode_id = (
int(value) for value in image_data_values[:4]
Expand All @@ -339,6 +340,8 @@ def read_comment(s: str) -> bool:
else:
break

# Read the columns and rows after checking the bit depth and mode
# in case the bit depth and/or mode are invalid.
imagedata_size = columns, rows
elif bytes_mv[:5] == b"%%EOF":
break
Expand Down

0 comments on commit 14e4961

Please sign in to comment.