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

PDF file size is huge, image is 759kb, and PDF file is 10MB #197

Open
hahazexia opened this issue Nov 14, 2024 · 2 comments
Open

PDF file size is huge, image is 759kb, and PDF file is 10MB #197

hahazexia opened this issue Nov 14, 2024 · 2 comments

Comments

@hahazexia
Copy link

I followed the official example and used the add_to_layer method to add a local image file to the page of a PDF file, but the final generated PDF file is particularly large! The size increased by 10 times. This is very strange. Do you have any ideas on how to solve this problem?

The original image file is 759 KB, and the final generated PDF file has become 10.3 MB.

here is my code https://github.com/hahazexia/img2pdf

image

image

@fschutt
Copy link
Owner

fschutt commented Nov 14, 2024

Use release mode? Images are uncompressed in debug mode. Image compression is on by default in 0.8, I think I only needed it when I was debugging images in the early days of this library.

@fschutt
Copy link
Owner

fschutt commented Nov 14, 2024

Well it's 5.2 MB with --release. Good, but not that much better. Technically we could use the JPXDecode filter (used to natively embed JPEGs into PDF), which would probably bring it close to the original (but at the loss of quality).

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

No branches or pull requests

2 participants