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

for some JPEG files PIL does not return DPI, but returns jfif_density #40

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dziket
Copy link

@dziket dziket commented Dec 28, 2024

For some JPEG files - for instance some produced by imagemagick - PIL does not return correct DPI, even though DPI is there, in files' headers. For such files img2pdf does not get their DPI, so it assumes it is 96. It causes that when generated PDF is displayed on a screen, pages' sizes are wrong.

To reproduce the problem, generate PDF from
these two JPEG files. When I do it with command:

$ python3 src/img2pdf.py page-1.jpg page-2.jpg -o output.pdf

it produces a PDF file with two pages and when the PDF is displayed on a screen, the sizes of the pages are different. Which is wrong: the dimensions of the two files measured in pixels are different, but they have different DPI, so their dimensions measured in centimeters should be the same.

I already reported a problem to Pillow, but until they fix it, the change in this pull request fixes the problem.

@dziket
Copy link
Author

dziket commented Dec 28, 2024

Hm, probably this change is not needed, because Pillow library is going to fix it:
python-pillow/Pillow#8633

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

Successfully merging this pull request may close these issues.

1 participant