Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion Tests/test_file_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def test_monochrome(tmp_path):
mode = "1"

# Act / Assert
helper_save_as_pdf(tmp_path, mode)
outfile = helper_save_as_pdf(tmp_path, mode)
assert os.path.getsize(outfile) < 15000


def test_greyscale(tmp_path):
Expand Down
8 changes: 1 addition & 7 deletions src/PIL/PdfImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def _save(im, fp, filename, save_all=False):
decode = None

if im.mode == "1":
filter = "ASCIIHexDecode"
filter = "DCTDecode"
colorspace = PdfParser.PdfName("DeviceGray")
procset = "ImageB" # grayscale
bits = 1
Expand Down Expand Up @@ -161,12 +161,6 @@ def _save(im, fp, filename, save_all=False):
op = io.BytesIO()

if filter == "ASCIIHexDecode":
if bits == 1:
# FIXME: the hex encoder doesn't support packed 1-bit
# images; do things the hard way...
data = im.tobytes("raw", "1")
im = Image.new("L", im.size)
im.putdata(data)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is now unused, so I have removed it.

ImageFile._save(im, op, [("hex", (0, 0) + im.size, 0, im.mode)])
elif filter == "DCTDecode":
Image.SAVE["JPEG"](im, op, filename)
Expand Down