Compress PDF file #2107
-
Hai jorj For example I am having more than 500MB pdf file. How to compress that file in fitz? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
The standard approach is using garbage collection and deflation. This will not change the PDF's appearance in any way. Depending on your willingness to bargain appearance for size, more things can be done with PyMuPDF - and some might have a very significant effect:
If any of the above finds your interest, we should discuss. |
Beta Was this translation helpful? Give feedback.
-
Hard to be sure what that is, because every viewer does these things differently. |
Beta Was this translation helpful? Give feedback.
-
Superb jorj it's working as expected thank you |
Beta Was this translation helpful? Give feedback.
-
Yes, you need the image xref. You also must provide the new image of course. If you want a JPG version of the existing image, you must make it: there is no automatism for this in PyMuPDF - and in fact, why should there be such a thing?
You can extract the current image, make a pixmap from it, then use `pix.tobytes("jpg")` and reinsert this output to replace the current image.
…________________________________
Von: kenho211 ***@***.***>
Gesendet: Donnerstag, 21. Dezember 2023 07:06
An: pymupdf/PyMuPDF ***@***.***>
Cc: Jorj X. McKie ***@***.***>; Comment ***@***.***>
Betreff: Re: [pymupdf/PyMuPDF] Compress PDF file (Discussion #2107)
How to replace the images from PNG to JPG?
Couldn't find relevant functions, do we have to do it using xref?
—
Reply to this email directly, view it on GitHub<#2107 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AB7IDIX77T6SSF64C6KMKT3YKQJ43AVCNFSM6AAAAAASWSK5EGVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TSMJXGE4DA>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
Superb jorj it's working as expected thank you