Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switched to saving 1-bit PDFs with DCTDecode #5430

Merged
merged 1 commit into from Apr 25, 2021

Conversation

radarhere
Copy link
Member

@radarhere radarhere commented Apr 22, 2021

Resolves #1775 - the remaining part of that issue is a request for compression when saving 1-bit PDFs.

The issue reports that

from PIL import Image
img = Image.new("1", (1400, 2000))
img.save("out.pdf")

generates a 5mb file.

Changing the filter to "DCTDecode", it becomes 34kb instead.

I've modified a test to ensure that saving hopper("1") as a PDF, that currently creates a 34kb file, stays below 15kb.

# 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.

@radarhere radarhere mentioned this pull request Apr 23, 2021
@hugovk hugovk merged commit dc817ea into python-pillow:master Apr 25, 2021
@radarhere radarhere deleted the pdf_1 branch April 25, 2021 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PDFs and 1 bit pixels
2 participants