python-pillow / python-pillow/Pillow

Raw formats (DNG, GPR, NEF)

Open
#6,482 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement TIFF
Dominant language
Python
Stars
13.8k
Forks
2.5k
Avg merge
2d 8h
Merged PRs (30d)
89

Description

What did you do?

I opened the images using Pillow and printed their detected size.

What did you expect to happen?

The size to be reported correctly. This causes conversions to JPEG to be way too small.

What actually happened?

Size was reported incorrectly.

What are your OS, Python and Pillow versions?
  • OS: EndeavourOS
  • Python: 3.10
  • Pillow: 9.2.0 (Also tested -git as of 05/08/22)
>>> from PIL import Image
>>> img = Image.open("sample.dng")
>>> img.width, img.height
(256, 195)
>>> img = Image.open("sample2.NEF")
>>> img.width, img.height
(160, 120)

Interestingly the file command also shows the wrong sizes:

$ file sample.dng
sample.dng: TIFF image data, little-endian, direntries=60, height=195, bps=734, compression=none, PhotometricIntepretation=RGB, manufacturer=NIKON CORPORATION, model=NIKON Z 7, orientation=upper-right, width=256

$ file sample2.NEF
sample2.NEF: TIFF image data, little-endian, direntries=28, height=120, bps=352, compression=none, PhotometricIntepretation=RGB, manufacturer=NIKON CORPORATION, model=NIKON D7200, orientation=upper-left, width=160

While inspecting the files with Dolphin shows the correct sizes:
image

sample.dng
sample2.NEF

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the linked sample.dng and sample2.NEF files using Pillow's Image.open entry point, checking the reported width and height against the sizes shown by Dolphin. Trace how these raw formats are identified and their dimensions are read. Done means both files report their actual dimensions and JPEG conversions are no longer undersized.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-vision
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.