Skip to content

Conversation

@radarhere
Copy link
Member

Resolves #8471

When adding type hints in #8270, I added a cast to float.

def _limit_rational(
val: float | Fraction | IFDRational, max_val: int
) -> tuple[IntegralLike, IntegralLike]:
inv = abs(float(val)) > 1

However, that is causing a ZeroDivisionError when the value is an IFDRational with a denominator of zero.

I'm able to remove the cast without causing a mypy error, so I've reverted that specific change.

I created a test image with

im = Image.new("1", (1, 1))
exif = im.getexif()
exif[34853] = {
    2: (IFDRational(0, 0), IFDRational(0, 0), IFDRational(0, 0))
}
im.save("gpsinfo_zero_latitude.jpg", exif=exif)

@radarhere
Copy link
Member Author

After fixing the type hint errors in #8474, the ZeroDivisionError starts occurring there.

So that PR can replace this one.

@radarhere radarhere closed this Oct 16, 2024
@radarhere radarhere deleted the gps branch October 17, 2024 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ZeroDivisionError: Caused by nan in GPS tags in EXIF Since release of Pillow 11.0

1 participant