ZeroDivisionError: float division by zero
#192
Open
opened 2 months ago by newadventure
·
5 comments
Loading…
Reference in New Issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Version
img2pdf 0.5.1
from homebrewPlatform: macOS
I viewed all images and none are corrupted or of 0 size/length
Can you provide me with an image that exhibits this behaviour? Thanks!
Also, the division by zero error comes from one of your images which has:
I wonder what img2pdf should do when it encounters such an image. According to your debug output, it should be the fourth image matching
/Users/me/Downloads/62'/*.jpg
.Yes, that's correct. macOS Preview opens it fine and its Inspector says the DPI is 300 pixels/inch
imagemagick thinks it's OK too:
The image is NSFW. Can I email it to you?
Yes, my private email is josch@mister-muffin.de.
Thank you for helping with getting to the bottom of this!
Okay, I have an analysis for this issue. Here are the first 32 bytes of the problematic image:
This is the JFIF APP0 segment and the density unit can be found at offset 13 and is 1 which corresponds to dots per inch. The two bytes after that are 0x12c which is 300 in decimal and the X resolution. The two bytes after that are the Y resolution and set to zero. This is why your image is problematic.