Skip to content

Commit 88420f6

Browse files
authored
Merge pull request #6749 from radarhere/exif_lightsource
Added LightSource tag values to ExifTags
2 parents 925e27c + 5c482e2 commit 88420f6

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

docs/reference/ExifTags.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@ which provide constants and clear-text names for various well-known EXIF tags.
3737
>>> IFD.Exif.value
3838
34665
3939
>>> IFD(34665).name
40-
'Exif'
40+
'Exif
41+
42+
.. py:data:: LightSource
43+
44+
>>> from PIL.ExifTags import LightSource
45+
>>> LightSource.Unknown.value
46+
0
47+
>>> LightSource(0).name
48+
'Unknown'
4149

4250
Two of these values are also exposed as dictionaries.
4351

docs/releasenotes/9.4.0.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,34 @@ removes the hidden RGB values for better compression by default in libwebp 0.5
4545
or later. By setting this option to ``True``, the encoder will keep the hidden
4646
RGB values.
4747

48+
Added IFD, Interop and LightSource ExifTags enums
49+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
50+
51+
:py:data:`~PIL.ExifTags.IFD` has been added, allowing enums to be used with
52+
:py:meth:`~PIL.Image.Exif.get_ifd`::
53+
54+
from PIL import Image, ExifTags
55+
im = Image.open("Tests/images/flower.jpg")
56+
print(im.getexif().get_ifd(ExifTags.IFD.Exif))
57+
58+
``IFD1`` can also be used with :py:meth:`~PIL.Image.Exif.get_ifd`, but it should
59+
not be used in other contexts, as the enum value is only internally meaningful.
60+
61+
:py:data:`~PIL.ExifTags.Interop` has been added for tags within the Interop IFD::
62+
63+
from PIL import Image, ExifTags
64+
im = Image.open("Tests/images/flower.jpg")
65+
interop_ifd = im.getexif().get_ifd(ExifTags.IFD.Interop)
66+
print(interop_ifd.get(ExifTags.Interop.InteropIndex)) # R98
67+
68+
:py:data:`~PIL.ExifTags.LightSource` has been added for values within the LightSource
69+
tag::
70+
71+
from PIL import Image, ExifTags
72+
im = Image.open("Tests/images/iptc.jpg")
73+
exif_ifd = im.getexif().get_ifd(ExifTags.IFD.Exif)
74+
print(ExifTags.LightSource(exif_ifd[0x9208])) # LightSource.Unknown
75+
4876
getxmp()
4977
^^^^^^^^
5078

src/PIL/ExifTags.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,3 +354,27 @@ class IFD(IntEnum):
354354
Makernote = 37500
355355
Interop = 40965
356356
IFD1 = -1
357+
358+
359+
class LightSource(IntEnum):
360+
Unknown = 0
361+
Daylight = 1
362+
Fluorescent = 2
363+
Tungsten = 3
364+
Flash = 4
365+
Fine = 9
366+
Cloudy = 10
367+
Shade = 11
368+
DaylightFluorescent = 12
369+
DayWhiteFluorescent = 13
370+
CoolWhiteFluorescent = 14
371+
WhiteFluorescent = 15
372+
StandardLightA = 17
373+
StandardLightB = 18
374+
StandardLightC = 19
375+
D55 = 20
376+
D65 = 21
377+
D75 = 22
378+
D50 = 23
379+
ISO = 24
380+
Other = 255

0 commit comments

Comments
 (0)