JPEG dpi read from EXIF uses XResolution for both axes
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 20/100
Línea de trabajo
The issue identifies _read_dpi_from_exif as the entry point but gives no file path or test location. Read that function and the JPEG DPI tests, then run the relevant tests with EXIF XResolution 300 and YResolution 150 while JFIF is absent. Done means the reported DPI preserves both axes as (300.0, 150.0); linked PR #10334 is already open.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
What did you do?
I'm building an image-optimization tool that prepares screenshots and photos for PDFs: it picks the output format, carries the DPI so pages place at the right size, and checks that lossless steps keep every pixel. Its test suite generates each input type Pillow opens and runs it through the tool, which is where this came up. A JPEG whose resolution is only in EXIF, XResolution 300 and YResolution 150, came back square.
import io
from PIL import Image
exif = Image.Exif()
exif[0x011A] = 300.0 # XResolution
exif[0x011B] = 150.0 # YResolution
exif[0x0128] = 2 # ResolutionUnit: inches
buf = io.BytesIO()
Image.new("RGB", (16, 16)).save(buf, "JPEG", exif=exif)
# Pillow writes a JFIF APP0 segment with units 0; drop it so DPI must come from EXIF
data = buf.getvalue()
app0_length = int.from_bytes(data[4:6], "big")
assert data[2:4] == b"\xff\xe0"
data = data[:2] + data[4 + app0_length:]
with Image.open(io.BytesIO(data)) as im:
print(im.info["dpi"])
What did you expect to happen?
(300.0, 150.0)
What actually happened?
(300.0, 300.0). _read_dpi_from_exif reads only 0x011A (XResolution) and sets (dpi, dpi), so YResolution never applies. The JFIF and TIFF paths report the two axes separately.
Related: #10332 (TIFF dpi with no resolution tags).
What are your OS, Python and Pillow versions?
- OS: Ubuntu 24.04 (Linux x86_64)
- Python: 3.13.13
- Pillow: 13.0.0 (also reproduces on 12.3.0)
--------------------------------------------------------------------
Pillow 13.0.0
Python 3.13.13 (main, May 10 2026, 19:26:54) [Clang 22.1.3 ]
--------------------------------------------------------------------
Python executable is ~/.venv/bin/python
Environment Python files loaded from ~/.venv
System Python files loaded from ~/.local/share/uv/python/cpython-3.13.13-linux-x86_64-gnu
--------------------------------------------------------------------
Python Pillow modules loaded from ~/.venv/lib/python3.13/site-packages/PIL
Binary Pillow modules loaded from ~/.venv/lib/python3.13/site-packages/PIL
--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 13.0.0
--- TKINTER support ok, loaded 9.0
--- FREETYPE2 support ok, loaded 2.14.3
--- LITTLECMS2 support ok, loaded 2.19
--- WEBP support ok, loaded 1.6.0
--- AVIF support ok, loaded 1.4.2
--- JPEG support ok, compiled for libjpeg-turbo 3.2.0
--- OPENJPEG (JPEG2000) support ok, loaded 2.5.4
--- ZLIB (PNG/ZIP) support ok, loaded 1.3, compiled for zlib-ng 2.3.3
--- LIBTIFF support ok, loaded 4.7.2
--- RAQM (Bidirectional Text) support ok, loaded 0.11.0, fribidi 1.0.13, harfbuzz 14.5.0
*** LIBIMAGEQUANT (Quantization method) support not installed
--- XCB (X protocol) support ok
--------------------------------------------------------------------
- Lenguaje dominante
- Python
- Estrellas
- 13.9k
- Forks
- 2.6k
- Merge medio
- 1 d 7 h
- PR fusionados (30 d)
- 174
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de python-pillow/Pillow
-
TIFF without XResolution/YResolution reports dpi (1, 1)Posiblemente ocupada @brettdavies la tomó hace 2 días. Abierto🤖-assisted TIFF
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
python-pillow/Pillow#10332 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Warn that pre-applying arabic_reshaper + python-bidi corrupts text on a Raqm buildPosiblemente ocupada @Syamjith-NK la tomó hace 61 días. AbiertoDocumentation Font Rendering PNG Third Party Framework
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
python-pillow/Pillow#9907 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Image.putpixel incorrectly labels supported arguments in type annotationsPosiblemente ocupada @radarhere la tomó hace 188 días. AbiertoPNG
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
python-pillow/Pillow#9584 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
JPEG saved with keep_rgb=True and dpi reopens with incorrect colorsPosiblemente ocupada @Muguett-DBY la tomó hace 1 día. Abierto🤖-assisted JPEG
Dificultad 4/5 1-2 días Aptitud para principiantes 25/100
python-pillow/Pillow#10344 ·
Los mantenedores suelen responder en 1 día
-
16-bit PNG tRNS key: convert("RGBA") misses the keyed pixel and makes another transparentPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. AbiertoConversion
Dificultad 3/5 1-2 días Aptitud para principiantes 58/100
python-pillow/Pillow#10330 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de python-pillow/Pillow
Issues similares
-
area/profiles comp/cli P3 type/feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
NousResearch/hermes-agent#146372 ·
Los mantenedores suelen responder en 1 día
-
[BUG] OpenAI-compatible embedding model alias breaks embedder constructionPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
[oblt-aw][autodoc] Document obs-aw-automerge contract and fix automerge doc inconsistenciesPosiblemente ocupada @github-actions la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
GeoSeries scale and skew tests fail with pytest 9.2.0Posiblemente ocupada @jiayuasu la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
admission-deferred priority: medium status: ready work-class: scoped
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
melodic-software/claude-code-plugins#10887 · 4 comentarios ·
Los mantenedores suelen responder en 1 día