za3k / qr-backup

Paper backup of files using QR codes
Other
128 stars 12 forks source link

All versions of Pillow > 8.2.0 create a PDF that doesn't work in most PDF readers I tried. #24

Closed arcanemachine closed 2 years ago

arcanemachine commented 2 years ago

EDIT: Using Pillow 8.2.0 generates uncorrupted PDFs.

Hello, this program is generating broken PDFs that do not display in any PDF view that I have tried, with the exception of Chrome.

In Linux, the PDF fails to open in Evince, Firefox, and Libreoffice Draw (this one crashes).

On Adroid, the PDF works in an old Google PDF reader app that I use, but fails in Moon Reader.

In all apps that display the PDF without crashing, the PDF looks the same: like a noisy, streaky mess.

I am using Xubuntu 21.04 x64.

I have tried a couple different files with the same result. To show my issues, I have attempted to create a backup of CHANGELOG from the latest commit (currently 926355d85ddd3fb8878da07e5cf464d47fb14569).

Here is a link to the PDF generated: https://filelink.org/kRWFohOf6Lur0RZ Here is an image of how it looks on my computer (on anything other than Chromium) and on Android Moon Reader: https://ibb.co/6J9XGJC

Here are the versions I have installed (via pip freeze from a venv):

Pillow==9.0.1
qrcode==7.3.1

Here is my terminal output from when I created the file:

(venv) user@host:~/code/git/qr-backup$ ./qr-backup CHANGELOG -v
INFO:root:Original arguments were: []
INFO:root:Command arguments parsed. Equivalent command: qr-backup --qr-version 10 --dpi 300 --scale 8 --error-correction L --page 500 600 --compress --filename CHANGELOG
INFO:root:read file CHANGELOG (sha b8d63ca5584ffa66aea55851e6fb9f60b5a10542086a95cfba2b5cd6479870a4, 2.731KB)
INFO:root:Restore command is: sort -u | grep "^N" | cut -c6- | base64 -d | gunzip
INFO:root:9 qr codes (at version 10) total
INFO:root:QR code (including label) is: 520x520px
INFO:root:Page is: 2083x2500px
INFO:root:4 x 4 qr codes (at version 10) per page. 1 pages total
INFO:root:1326 bytes in 1 (2.73KB/page)
WARNING:root:Skipping digital restore verification, because zbarimg is not available.
za3k commented 2 years ago

This sounds almost certain to be a Pillow bug, would you be willing to bisect down to the specific version that introduced it?

Ex tell me 8.2.0 works but 8.3.0 fails.

arcanemachine commented 2 years ago

That is correct: 8.2.0 works but 8.3.0 fails.

za3k commented 2 years ago

Reported upstream to PIL/Pillow. Added a workaround until they fix it.