Repository navigation
Commit c6513e5
fix: Image.metadata() missing camera-specific Exif sub-IFD tags
Image.getexif() (the modern public Pillow API) only returns the
top-level IFD0 tags (Make, Model, Orientation, ...). Camera-specific
tags -- FocalLength, ExposureTime, FNumber, ISOSpeedRatings, LensModel,
etc. -- live in a separate "Exif" sub-IFD that getexif() does not
flatten in. metadata() never fetched that sub-IFD, so
img.metadata("FocalLength") always raised KeyError even though the
tag is genuinely present in the file (confirmed via raw PIL: it's
under Exif.get_ifd(0x8769), the fixed EXIF-spec tag id for the Exif
IFD pointer).
This is a Pillow API evolution, not a data problem: the old private
Image._getexif() used to flatten everything into one dict; the public
getexif() introduced later deliberately does not, requiring an
explicit get_ifd() call for the sub-IFD.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>1 parent ee58434 commit c6513e5
2 files changed
Lines changed: 23 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
270 | 278 | | |
271 | 279 | | |
272 | 280 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
194 | 193 | | |
195 | 194 | | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
201 | 210 | | |
202 | 211 | | |
203 | 212 | | |
| |||
0 commit comments