python-pillow / Pillow

Python Imaging Library (Fork)
https://python-pillow.org
Other
12.32k stars 2.23k forks source link

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

Closed bashirmindee closed 1 month ago

bashirmindee commented 1 month ago

What did you do?

Thank you for this amazing library <3.

Since release of Pillow 11.0, I have a problem rotating some files using Pillow.

What did you expect to happen?

rotated image to be produced in rotated_img

What actually happened?

ZeroDivisionError due to nan in GPS data.

What are your OS, Python and Pillow versions?

Please paste here the output of running: python3 -m PIL.report

--------------------------------------------------------------------
Pillow 11.0.0
Python 3.11.10+ (heads/3.11:8b275e7, Sep  9 2024, 18:31:31) [GCC 13.2.0]
--------------------------------------------------------------------
Python executable is /home/bashir/mindee/teamMindee/input-pipeline/venv/bin/python3
Environment Python files loaded from /home/bashir/mindee/teamMindee/input-pipeline/venv
System Python files loaded from /home/bashir/.pyenv/versions/3.11-dev
--------------------------------------------------------------------
Python Pillow modules loaded from /home/bashir/mindee/teamMindee/input-pipeline/venv/lib/python3.11/site-packages/PIL
Binary Pillow modules loaded from /home/bashir/mindee/teamMindee/input-pipeline/venv/lib/python3.11/site-packages/PIL
--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 11.0.0
--- TKINTER support ok, loaded 8.6
--- FREETYPE2 support ok, loaded 2.13.2
--- LITTLECMS2 support ok, loaded 2.16
--- WEBP support ok, loaded 1.4.0
--- JPEG support ok, compiled for libjpeg-turbo 3.0.4
--- OPENJPEG (JPEG2000) support ok, loaded 2.5.2
--- ZLIB (PNG/ZIP) support ok, loaded 1.3
--- LIBTIFF support ok, loaded 4.6.0
--- RAQM (Bidirectional Text) support ok, loaded 0.10.1, fribidi 1.0.13, harfbuzz 10.0.1
*** LIBIMAGEQUANT (Quantization method) support not installed
--- XCB (X protocol) support ok
--------------------------------------------------------------------
from PIL.ImageOps import exif_transpose
from PIL.Image import open as pil_open

filepath = "/path/to/file.jpg"

with pil_open(filepath) as pillow_img:
    rotated_img = exif_transpose(pillow_img)

output.jpg.tar.gz

radarhere commented 1 month ago

8474 will resolve this.