Skip to content

Commit

Permalink
STY: Use generator expressions (#3016)
Browse files Browse the repository at this point in the history
  • Loading branch information
j-t-1 authored Dec 21, 2024
1 parent dd6178b commit d24bce5
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions pypdf/_xobj_image_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def _extended_image_frombytes(
if data_length % nb_pix != 0:
raise exc
k = nb_pix * len(mode) / data_length
data = b"".join([bytes((x,) * int(k)) for x in data])
data = b"".join(bytes((x,) * int(k)) for x in data)
img = Image.frombytes(mode, size, data)
return img

Expand Down Expand Up @@ -226,15 +226,11 @@ def _handle_flate(
lookup = lookup[:expected_count]
colors_arr = [lookup[:nb], lookup[nb:]]
arr = b"".join(
[
b"".join(
[
colors_arr[1 if img.getpixel((x, y)) > 127 else 0]
for x in range(img.size[0])
]
)
for y in range(img.size[1])
]
b"".join(
colors_arr[1 if img.getpixel((x, y)) > 127 else 0]
for x in range(img.size[0])
)
for y in range(img.size[1])
)
img = Image.frombytes(mode, img.size, arr)
else:
Expand Down

0 comments on commit d24bce5

Please sign in to comment.