TIFF without XResolution/YResolution reports dpi (1, 1)
维护者通常 1 天内回复
已经有一个关联 PR 被合并了。
- #10339 来自 @brettdavies —— 已合并
评估
调研方向
首先追踪 TIFF 插件如何将 XResolution、YResolution 和 ResolutionUnit 读入 im.info,然后与 issue 中提到的 PNG 和 JPEG 行为进行比较。为未包含分辨率标签而保存的 TIFF 添加或调整回归测试,并检查其 dpi 键不存在;保留包含分辨率标签的 TIFF 的预期行为。
由索引模型根据 Issue 内容生成。
描述
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 TIFF saved without resolution tags reported dpi == (1, 1), and the tool carried 1 DPI into its PNG and JPEG output, which a DPI-aware PDF tool would place at 96 inches wide for a 96-pixel image.
import io
from PIL import Image
buf = io.BytesIO()
Image.new("L", (16, 16)).save(buf, "TIFF")
with Image.open(buf) as im:
print(im.tag_v2.get(282), im.tag_v2.get(283), im.tag_v2.get(296))
print(im.info.get("dpi"), im.info.get("resolution"))
What did you expect to happen?
No dpi key, as for a PNG or JPEG saved without resolution.
What actually happened?
None None None
(1, 1) (1, 1)
xres = self.tag_v2.get(X_RESOLUTION, 1) and the same for Y supply 1 when the tags are absent. I understand this may be kept for compatibility; #10187 dropped BMP's (0, 0) placeholder in the same spirit.
Related: #10331 (JPEG dpi read from EXIF).
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
--------------------------------------------------------------------
- 主要语言
- Python
- 星标
- 13.9k
- 派生
- 2.6k
- 平均合并
- 1 天 4 小时
- 30 天内合并 PR
- 173
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
python-pillow/Pillow 的其他 Issue
-
Warn that pre-applying arabic_reshaper + python-bidi corrupts text on a Raqm build可能已有人在做 @Syamjith-NK 于 61 天前认领。 未关闭Documentation Font Rendering PNG Third Party Framework
难度 2/5 1-3 小时 新手友好度 78/100
python-pillow/Pillow#9907 · 2 条评论 ·
维护者通常 1 天内回复
-
Image.putpixel incorrectly labels supported arguments in type annotations可能已有人在做 @radarhere 于 189 天前认领。 未关闭PNG
难度 2/5 1-3 小时 新手友好度 70/100
python-pillow/Pillow#9584 · 1 条评论 ·
维护者通常 1 天内回复
-
`ImageDraw.arc()` segfaults on a tuple subclass whose `__len__` is too large可能已有人在做 @Parsiffall1 今天认领。 未关闭
难度 4/5 1-2 天 新手友好度 58/100
python-pillow/Pillow#10358 ·
维护者通常 1 天内回复
-
JPEG saved with keep_rgb=True and dpi reopens with incorrect colors可能已有人在做 @Muguett-DBY 于 2 天前认领。 未关闭🤖-assisted JPEG
难度 4/5 1-2 天 新手友好度 25/100
python-pillow/Pillow#10344 ·
维护者通常 1 天内回复
-
JPEG dpi read from EXIF uses XResolution for both axes可能已有人在做 @unvisible789 于 3 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 20/100
python-pillow/Pillow#10331 · 1 条评论 ·
维护者通常 1 天内回复
查看 python-pillow/Pillow 的全部 Issue
相似的 Issue
-
Support .aac audio uploads可能已有人在做 @julien731 今天认领。 未关闭feature
难度 2/5 1-3 小时 新手友好度 78/100
nimblehq/audio-transcriber#153 ·
-
help wanted
难度 2/5 1-3 小时 新手友好度 68/100
antonyrag/ragleap-core#1062 ·
-
needs-triage
难度 2/5 1-3 小时 新手友好度 76/100
gke-labs/kube-agents#4321 ·
维护者通常 1 天内回复
-
enhancement help wanted
难度 2/5 1-3 小时 新手友好度 76/100
Git-Hospital/githealthcheck#61 ·
维护者通常 1 天内回复
-
changelog investigate
难度 2/5 1-3 小时 新手友好度 67/100
ramnes/notion-sdk-py#433 ·