Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

TIFF without XResolution/YResolution reports dpi (1, 1)

Đã đóng Phù hợp với người mới
#10,332 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Một pull request liên quan đã được merge.

  • #10339 của @brettdavies — đã merge

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
75/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

Trước tiên, hãy theo dõi cách plugin TIFF đọc XResolution, YResolution và ResolutionUnit vào im.info, sau đó so sánh với cách PNG và JPEG hoạt động như được đề cập trong issue. Thêm hoặc điều chỉnh một bài kiểm thử hồi quy cho TIFF được lưu mà không có thẻ độ phân giải và kiểm tra xem khóa dpi có bị thiếu hay không; giữ nguyên hành vi mong đợi đối với TIFF có thẻ độ phân giải.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

🤖-assisted TIFF
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
--------------------------------------------------------------------
Ngôn ngữ chính
Python
Star
13.9k
Fork
2.6k
Merge trung bình
1 ngày 4 giờ
Pull request đã merge (30 ngày)
173

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của python-pillow/Pillow

Tất cả issue của python-pillow/Pillow

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.