for some JPEG files PIL does not return DPI, but returns jfif_density#40
Open
dziket wants to merge 1 commit intojosch:mainfrom
Open
for some JPEG files PIL does not return DPI, but returns jfif_density#40dziket wants to merge 1 commit intojosch:mainfrom
dziket wants to merge 1 commit intojosch:mainfrom
Conversation
Author
|
Hm, probably this change is not needed, because Pillow library is going to fix it: |
Owner
|
Hi, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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.