Skip to content

Commit

Permalink
BUG: Convert color space before saving
Browse files Browse the repository at this point in the history
The PDF contained an image in PA mode:
* P: 8-bit pixels, mapped to any other mode using a color palette
* PA: P with alpha

See #1801
  • Loading branch information
MartinThoma committed Apr 17, 2023
1 parent f8295a9 commit 5e53bba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pypdf/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ def _xobj_to_image(x_object_obj: Dict[str, Any]) -> Tuple[Optional[str], bytes]:
alpha = Image.frombytes("L", size, x_object_obj[G.S_MASK].get_data())
img.putalpha(alpha)
img_byte_arr = BytesIO()
img.save(img_byte_arr, format="PNG")
img.convert("RGB").save(img_byte_arr, format="PNG")
data = img_byte_arr.getvalue()
elif x_object_obj[SA.FILTER] in (
[FT.LZW_DECODE],
Expand Down

0 comments on commit 5e53bba

Please sign in to comment.