Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

About set PDF Filter #3670

Closed
Syntamin opened this issue Jul 9, 2024 · 2 comments
Closed

About set PDF Filter #3670

Syntamin opened this issue Jul 9, 2024 · 2 comments

Comments

@Syntamin
Copy link

Syntamin commented Jul 9, 2024

Description of the bug

About set PDF Filter

How to reproduce the bug

Hello,

During my process of compressing PDFs using PyMuPDF, I noticed that after converting images to JPEG, the original object's Filter is set to /DCTDecode. However, when I used other online tools to compress PDFs, I observed that they seem to employ two layers of compression: one with JPEG compression (setting the Quality to 60 in DecodeParms), and another with the FlateDecode filter. This approach seems to significantly reduce the PDF size.

I would like to know if it is possible to achieve this using PyMuPDF. If so, after setting the Filter entry for the object, what additional steps are required to handle the content stream properly?

Thank you for your assistance.

Best regards,
Syntamin

PyMuPDF version

1.24.7

Operating system

MacOS

Python version

3.11

@Syntamin
Copy link
Author

Syntamin commented Jul 9, 2024

This is an object from a PDF compressed using an online tool:

<<
/Type /XObject
/Subtype /Image
/Width 1232
/Height 1280
/BitsPerComponent 8
/ColorSpace /DeviceGray
/Filter [/FlateDecode /DCTDecode]
/DecodeParms [null <<
/Quality 60
>>]
/Length 13389
>>
stream

And this is my an object:

3 0 obj
<</Type/XObject/Subtype/Image/Length 310642/Width 1280/Height 1280/BitsPerComponent 8/SMask null/ColorSpace/DeviceRGB/Filter/DCTDecode>>
stream

@JorjMcKie
Copy link
Collaborator

No, MuPDF does not support this.
This is no issue but a Discussions item ... transferring.

@pymupdf pymupdf locked and limited conversation to collaborators Jul 9, 2024
@JorjMcKie JorjMcKie converted this issue into discussion #3671 Jul 9, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants