py-pdf / fpdf2

Simple PDF generation for Python
https://py-pdf.github.io/fpdf2/
GNU Lesser General Public License v3.0
1.12k stars 253 forks source link

Add support for LZWDecode compression #1271

Closed Lucas-C closed 1 month ago

Lucas-C commented 1 month ago

Please explain your intent Currently fpdf2 supports 4 compression methods for images: https://github.com/py-pdf/fpdf2/blob/2.8.0/fpdf/image_parsing.py#L35

The PDF standard specification (cf. PDF32000_2008.pdf section 7.4 Filters) defines several other compression filters, including LZWDecode.

Recently, this filter was implemented by @MartinThoma in our companion library pypdf: https://github.com/py-pdf/pypdf/pull/2883

Describe the solution you'd like Support LZWDecode for images compression.

opposss commented 1 month ago

Hi!

I'd love to work on this issue can you assign me?

Lucas-C commented 1 month ago

Sure, done!

Lucas-C commented 1 month ago

Hi @opposss

Have you been able to start working on this implementation? Do you have any questions?

opposss commented 1 month ago

Hi @Lucas-C

Almost done, I will send the PR for review soon. Before that I would like to ask 2 questions:

1) Do I understand correctly that I can completely use the code that was written by @MartinThoma ?

2) Should I add logic to use the LZW filter in case of GIF images or other image formats?

Lucas-C commented 1 month ago

Almost done, I will send the PR for review soon.

Great! 👍

  1. Do I understand correctly that I can completely use the code that was written by @MartinThoma ?

Yes!

  1. Should I add logic to use the LZW filter in case of GIF images or other image formats?

If you can find a mention that this is supported, in the PDF spec (PDF32000_2008.pdf), or that main PDF readers support it (Adobe Acrobat, Sumatra PDF, MuPDF, web browsers...), then yes!

Lucas-C commented 1 month ago

This was implemented by @opposss in PR https://github.com/py-pdf/fpdf2/pull/1286