TIFF without XResolution/YResolution reports dpi (1, 1)
メンテナーはふだん 1 日以内に返信
関連するプルリクエストがすでにマージされています。
- #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時間
- マージ済み PR(30日)
- 173
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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
-
priority middle
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
KATO-Hiro/AtCoderClans#12940 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 76/100
huggingface/huggingface_hub#5283 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信
-
bug example
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信