Added enums

This commit is contained in:
Andrew Murray 2022-10-01 17:24:35 +10:00
parent bdbf59d151
commit d03f35b5bb
2 changed files with 336 additions and 308 deletions

View File

@ -11,7 +11,7 @@ provide constants and clear-text names for various well-known EXIF tags.
:type: dict :type: dict
The TAGS dictionary maps 16-bit integer EXIF tag enumerations to The TAGS dictionary maps 16-bit integer EXIF tag enumerations to
descriptive string names. For instance: descriptive string names. For instance:
>>> from PIL.ExifTags import TAGS >>> from PIL.ExifTags import TAGS
>>> TAGS[0x010e] >>> TAGS[0x010e]
@ -20,9 +20,28 @@ provide constants and clear-text names for various well-known EXIF tags.
.. py:data:: GPSTAGS .. py:data:: GPSTAGS
:type: dict :type: dict
The GPSTAGS dictionary maps 8-bit integer EXIF gps enumerations to The GPSTAGS dictionary maps 8-bit integer EXIF GPS enumerations to
descriptive string names. For instance: descriptive string names. For instance:
>>> from PIL.ExifTags import GPSTAGS >>> from PIL.ExifTags import GPSTAGS
>>> GPSTAGS[20] >>> GPSTAGS[20]
'GPSDestLatitude' 'GPSDestLatitude'
These values are also exposed as ``enum.IntEnum`` classes.
.. py:data:: Base
>>> from PIL.ExifTags import Base
>>> Base.ImageDescription.value
270
>>> Base(270).name
'ImageDescription'
.. py:data:: GPS
>>> from PIL.ExifTags import GPS
>>> GPS.GPSDestLatitude.value
20
>>> GPS(20).name
'GPSDestLatitude'

View File

@ -14,318 +14,327 @@ This module provides constants and clear-text names for various
well-known EXIF tags. well-known EXIF tags.
""" """
from enum import IntEnum
TAGS = {
class Base(IntEnum):
# possibly incomplete # possibly incomplete
0x0001: "InteropIndex", InteropIndex = 0x0001
0x000B: "ProcessingSoftware", ProcessingSoftware = 0x000B
0x00FE: "NewSubfileType", NewSubfileType = 0x00FE
0x00FF: "SubfileType", SubfileType = 0x00FF
0x0100: "ImageWidth", ImageWidth = 0x0100
0x0101: "ImageLength", ImageLength = 0x0101
0x0102: "BitsPerSample", BitsPerSample = 0x0102
0x0103: "Compression", Compression = 0x0103
0x0106: "PhotometricInterpretation", PhotometricInterpretation = 0x0106
0x0107: "Thresholding", Thresholding = 0x0107
0x0108: "CellWidth", CellWidth = 0x0108
0x0109: "CellLength", CellLength = 0x0109
0x010A: "FillOrder", FillOrder = 0x010A
0x010D: "DocumentName", DocumentName = 0x010D
0x010E: "ImageDescription", ImageDescription = 0x010E
0x010F: "Make", Make = 0x010F
0x0110: "Model", Model = 0x0110
0x0111: "StripOffsets", StripOffsets = 0x0111
0x0112: "Orientation", Orientation = 0x0112
0x0115: "SamplesPerPixel", SamplesPerPixel = 0x0115
0x0116: "RowsPerStrip", RowsPerStrip = 0x0116
0x0117: "StripByteCounts", StripByteCounts = 0x0117
0x0118: "MinSampleValue", MinSampleValue = 0x0118
0x0119: "MaxSampleValue", MaxSampleValue = 0x0119
0x011A: "XResolution", XResolution = 0x011A
0x011B: "YResolution", YResolution = 0x011B
0x011C: "PlanarConfiguration", PlanarConfiguration = 0x011C
0x011D: "PageName", PageName = 0x011D
0x0120: "FreeOffsets", FreeOffsets = 0x0120
0x0121: "FreeByteCounts", FreeByteCounts = 0x0121
0x0122: "GrayResponseUnit", GrayResponseUnit = 0x0122
0x0123: "GrayResponseCurve", GrayResponseCurve = 0x0123
0x0124: "T4Options", T4Options = 0x0124
0x0125: "T6Options", T6Options = 0x0125
0x0128: "ResolutionUnit", ResolutionUnit = 0x0128
0x0129: "PageNumber", PageNumber = 0x0129
0x012D: "TransferFunction", TransferFunction = 0x012D
0x0131: "Software", Software = 0x0131
0x0132: "DateTime", DateTime = 0x0132
0x013B: "Artist", Artist = 0x013B
0x013C: "HostComputer", HostComputer = 0x013C
0x013D: "Predictor", Predictor = 0x013D
0x013E: "WhitePoint", WhitePoint = 0x013E
0x013F: "PrimaryChromaticities", PrimaryChromaticities = 0x013F
0x0140: "ColorMap", ColorMap = 0x0140
0x0141: "HalftoneHints", HalftoneHints = 0x0141
0x0142: "TileWidth", TileWidth = 0x0142
0x0143: "TileLength", TileLength = 0x0143
0x0144: "TileOffsets", TileOffsets = 0x0144
0x0145: "TileByteCounts", TileByteCounts = 0x0145
0x014A: "SubIFDs", SubIFDs = 0x014A
0x014C: "InkSet", InkSet = 0x014C
0x014D: "InkNames", InkNames = 0x014D
0x014E: "NumberOfInks", NumberOfInks = 0x014E
0x0150: "DotRange", DotRange = 0x0150
0x0151: "TargetPrinter", TargetPrinter = 0x0151
0x0152: "ExtraSamples", ExtraSamples = 0x0152
0x0153: "SampleFormat", SampleFormat = 0x0153
0x0154: "SMinSampleValue", SMinSampleValue = 0x0154
0x0155: "SMaxSampleValue", SMaxSampleValue = 0x0155
0x0156: "TransferRange", TransferRange = 0x0156
0x0157: "ClipPath", ClipPath = 0x0157
0x0158: "XClipPathUnits", XClipPathUnits = 0x0158
0x0159: "YClipPathUnits", YClipPathUnits = 0x0159
0x015A: "Indexed", Indexed = 0x015A
0x015B: "JPEGTables", JPEGTables = 0x015B
0x015F: "OPIProxy", OPIProxy = 0x015F
0x0200: "JPEGProc", JPEGProc = 0x0200
0x0201: "JpegIFOffset", JpegIFOffset = 0x0201
0x0202: "JpegIFByteCount", JpegIFByteCount = 0x0202
0x0203: "JpegRestartInterval", JpegRestartInterval = 0x0203
0x0205: "JpegLosslessPredictors", JpegLosslessPredictors = 0x0205
0x0206: "JpegPointTransforms", JpegPointTransforms = 0x0206
0x0207: "JpegQTables", JpegQTables = 0x0207
0x0208: "JpegDCTables", JpegDCTables = 0x0208
0x0209: "JpegACTables", JpegACTables = 0x0209
0x0211: "YCbCrCoefficients", YCbCrCoefficients = 0x0211
0x0212: "YCbCrSubSampling", YCbCrSubSampling = 0x0212
0x0213: "YCbCrPositioning", YCbCrPositioning = 0x0213
0x0214: "ReferenceBlackWhite", ReferenceBlackWhite = 0x0214
0x02BC: "XMLPacket", XMLPacket = 0x02BC
0x1000: "RelatedImageFileFormat", RelatedImageFileFormat = 0x1000
0x1001: "RelatedImageWidth", RelatedImageWidth = 0x1001
0x1002: "RelatedImageLength", RelatedImageLength = 0x1002
0x4746: "Rating", Rating = 0x4746
0x4749: "RatingPercent", RatingPercent = 0x4749
0x800D: "ImageID", ImageID = 0x800D
0x828D: "CFARepeatPatternDim", CFARepeatPatternDim = 0x828D
0x828E: "CFAPattern", BatteryLevel = 0x828F
0x828F: "BatteryLevel", Copyright = 0x8298
0x8298: "Copyright", ExposureTime = 0x829A
0x829A: "ExposureTime", FNumber = 0x829D
0x829D: "FNumber", IPTCNAA = 0x83BB
0x83BB: "IPTCNAA", ImageResources = 0x8649
0x8649: "ImageResources", ExifOffset = 0x8769
0x8769: "ExifOffset", InterColorProfile = 0x8773
0x8773: "InterColorProfile", ExposureProgram = 0x8822
0x8822: "ExposureProgram", SpectralSensitivity = 0x8824
0x8824: "SpectralSensitivity", GPSInfo = 0x8825
0x8825: "GPSInfo", ISOSpeedRatings = 0x8827
0x8827: "ISOSpeedRatings", OECF = 0x8828
0x8828: "OECF", Interlace = 0x8829
0x8829: "Interlace", TimeZoneOffset = 0x882A
0x882A: "TimeZoneOffset", SelfTimerMode = 0x882B
0x882B: "SelfTimerMode", SensitivityType = 0x8830
0x8830: "SensitivityType", StandardOutputSensitivity = 0x8831
0x8831: "StandardOutputSensitivity", RecommendedExposureIndex = 0x8832
0x8832: "RecommendedExposureIndex", ISOSpeed = 0x8833
0x8833: "ISOSpeed", ISOSpeedLatitudeyyy = 0x8834
0x8834: "ISOSpeedLatitudeyyy", ISOSpeedLatitudezzz = 0x8835
0x8835: "ISOSpeedLatitudezzz", ExifVersion = 0x9000
0x9000: "ExifVersion", DateTimeOriginal = 0x9003
0x9003: "DateTimeOriginal", DateTimeDigitized = 0x9004
0x9004: "DateTimeDigitized", OffsetTime = 0x9010
0x9010: "OffsetTime", OffsetTimeOriginal = 0x9011
0x9011: "OffsetTimeOriginal", OffsetTimeDigitized = 0x9012
0x9012: "OffsetTimeDigitized", ComponentsConfiguration = 0x9101
0x9101: "ComponentsConfiguration", CompressedBitsPerPixel = 0x9102
0x9102: "CompressedBitsPerPixel", ShutterSpeedValue = 0x9201
0x9201: "ShutterSpeedValue", ApertureValue = 0x9202
0x9202: "ApertureValue", BrightnessValue = 0x9203
0x9203: "BrightnessValue", ExposureBiasValue = 0x9204
0x9204: "ExposureBiasValue", MaxApertureValue = 0x9205
0x9205: "MaxApertureValue", SubjectDistance = 0x9206
0x9206: "SubjectDistance", MeteringMode = 0x9207
0x9207: "MeteringMode", LightSource = 0x9208
0x9208: "LightSource", Flash = 0x9209
0x9209: "Flash", FocalLength = 0x920A
0x920A: "FocalLength", Noise = 0x920D
0x920B: "FlashEnergy", ImageNumber = 0x9211
SecurityClassification = 0x9212
ImageHistory = 0x9213
TIFFEPStandardID = 0x9216
MakerNote = 0x927C
UserComment = 0x9286
SubsecTime = 0x9290
SubsecTimeOriginal = 0x9291
SubsecTimeDigitized = 0x9292
AmbientTemperature = 0x9400
Humidity = 0x9401
Pressure = 0x9402
WaterDepth = 0x9403
Acceleration = 0x9404
CameraElevationAngle = 0x9405
XPTitle = 0x9C9B
XPComment = 0x9C9C
XPAuthor = 0x9C9D
XPKeywords = 0x9C9E
XPSubject = 0x9C9F
FlashPixVersion = 0xA000
ColorSpace = 0xA001
ExifImageWidth = 0xA002
ExifImageHeight = 0xA003
RelatedSoundFile = 0xA004
ExifInteroperabilityOffset = 0xA005
FlashEnergy = 0xA20B
SpatialFrequencyResponse = 0xA20C
FocalPlaneXResolution = 0xA20E
FocalPlaneYResolution = 0xA20F
FocalPlaneResolutionUnit = 0xA210
SubjectLocation = 0xA214
ExposureIndex = 0xA215
SensingMethod = 0xA217
FileSource = 0xA300
SceneType = 0xA301
CFAPattern = 0xA302
CustomRendered = 0xA401
ExposureMode = 0xA402
WhiteBalance = 0xA403
DigitalZoomRatio = 0xA404
FocalLengthIn35mmFilm = 0xA405
SceneCaptureType = 0xA406
GainControl = 0xA407
Contrast = 0xA408
Saturation = 0xA409
Sharpness = 0xA40A
DeviceSettingDescription = 0xA40B
SubjectDistanceRange = 0xA40C
ImageUniqueID = 0xA420
CameraOwnerName = 0xA430
BodySerialNumber = 0xA431
LensSpecification = 0xA432
LensMake = 0xA433
LensModel = 0xA434
LensSerialNumber = 0xA435
CompositeImage = 0xA460
CompositeImageCount = 0xA461
CompositeImageExposureTimes = 0xA462
Gamma = 0xA500
PrintImageMatching = 0xC4A5
DNGVersion = 0xC612
DNGBackwardVersion = 0xC613
UniqueCameraModel = 0xC614
LocalizedCameraModel = 0xC615
CFAPlaneColor = 0xC616
CFALayout = 0xC617
LinearizationTable = 0xC618
BlackLevelRepeatDim = 0xC619
BlackLevel = 0xC61A
BlackLevelDeltaH = 0xC61B
BlackLevelDeltaV = 0xC61C
WhiteLevel = 0xC61D
DefaultScale = 0xC61E
DefaultCropOrigin = 0xC61F
DefaultCropSize = 0xC620
ColorMatrix1 = 0xC621
ColorMatrix2 = 0xC622
CameraCalibration1 = 0xC623
CameraCalibration2 = 0xC624
ReductionMatrix1 = 0xC625
ReductionMatrix2 = 0xC626
AnalogBalance = 0xC627
AsShotNeutral = 0xC628
AsShotWhiteXY = 0xC629
BaselineExposure = 0xC62A
BaselineNoise = 0xC62B
BaselineSharpness = 0xC62C
BayerGreenSplit = 0xC62D
LinearResponseLimit = 0xC62E
CameraSerialNumber = 0xC62F
LensInfo = 0xC630
ChromaBlurRadius = 0xC631
AntiAliasStrength = 0xC632
ShadowScale = 0xC633
DNGPrivateData = 0xC634
MakerNoteSafety = 0xC635
CalibrationIlluminant1 = 0xC65A
CalibrationIlluminant2 = 0xC65B
BestQualityScale = 0xC65C
RawDataUniqueID = 0xC65D
OriginalRawFileName = 0xC68B
OriginalRawFileData = 0xC68C
ActiveArea = 0xC68D
MaskedAreas = 0xC68E
AsShotICCProfile = 0xC68F
AsShotPreProfileMatrix = 0xC690
CurrentICCProfile = 0xC691
CurrentPreProfileMatrix = 0xC692
ColorimetricReference = 0xC6BF
CameraCalibrationSignature = 0xC6F3
ProfileCalibrationSignature = 0xC6F4
AsShotProfileName = 0xC6F6
NoiseReductionApplied = 0xC6F7
ProfileName = 0xC6F8
ProfileHueSatMapDims = 0xC6F9
ProfileHueSatMapData1 = 0xC6FA
ProfileHueSatMapData2 = 0xC6FB
ProfileToneCurve = 0xC6FC
ProfileEmbedPolicy = 0xC6FD
ProfileCopyright = 0xC6FE
ForwardMatrix1 = 0xC714
ForwardMatrix2 = 0xC715
PreviewApplicationName = 0xC716
PreviewApplicationVersion = 0xC717
PreviewSettingsName = 0xC718
PreviewSettingsDigest = 0xC719
PreviewColorSpace = 0xC71A
PreviewDateTime = 0xC71B
RawImageDigest = 0xC71C
OriginalRawFileDigest = 0xC71D
SubTileBlockSize = 0xC71E
RowInterleaveFactor = 0xC71F
ProfileLookTableDims = 0xC725
ProfileLookTableData = 0xC726
OpcodeList1 = 0xC740
OpcodeList2 = 0xC741
OpcodeList3 = 0xC74E
NoiseProfile = 0xC761
"""Maps EXIF tags to tag names."""
TAGS = {
**{i.value: i.name for i in Base},
0x920C: "SpatialFrequencyResponse", 0x920C: "SpatialFrequencyResponse",
0x920D: "Noise",
0x9211: "ImageNumber",
0x9212: "SecurityClassification",
0x9213: "ImageHistory",
0x9214: "SubjectLocation", 0x9214: "SubjectLocation",
0x9215: "ExposureIndex", 0x9215: "ExposureIndex",
0x828E: "CFAPattern",
0x920B: "FlashEnergy",
0x9216: "TIFF/EPStandardID", 0x9216: "TIFF/EPStandardID",
0x927C: "MakerNote",
0x9286: "UserComment",
0x9290: "SubsecTime",
0x9291: "SubsecTimeOriginal",
0x9292: "SubsecTimeDigitized",
0x9400: "AmbientTemperature",
0x9401: "Humidity",
0x9402: "Pressure",
0x9403: "WaterDepth",
0x9404: "Acceleration",
0x9405: "CameraElevationAngle",
0x9C9B: "XPTitle",
0x9C9C: "XPComment",
0x9C9D: "XPAuthor",
0x9C9E: "XPKeywords",
0x9C9F: "XPSubject",
0xA000: "FlashPixVersion",
0xA001: "ColorSpace",
0xA002: "ExifImageWidth",
0xA003: "ExifImageHeight",
0xA004: "RelatedSoundFile",
0xA005: "ExifInteroperabilityOffset",
0xA20B: "FlashEnergy",
0xA20C: "SpatialFrequencyResponse",
0xA20E: "FocalPlaneXResolution",
0xA20F: "FocalPlaneYResolution",
0xA210: "FocalPlaneResolutionUnit",
0xA214: "SubjectLocation",
0xA215: "ExposureIndex",
0xA217: "SensingMethod",
0xA300: "FileSource",
0xA301: "SceneType",
0xA302: "CFAPattern",
0xA401: "CustomRendered",
0xA402: "ExposureMode",
0xA403: "WhiteBalance",
0xA404: "DigitalZoomRatio",
0xA405: "FocalLengthIn35mmFilm",
0xA406: "SceneCaptureType",
0xA407: "GainControl",
0xA408: "Contrast",
0xA409: "Saturation",
0xA40A: "Sharpness",
0xA40B: "DeviceSettingDescription",
0xA40C: "SubjectDistanceRange",
0xA420: "ImageUniqueID",
0xA430: "CameraOwnerName",
0xA431: "BodySerialNumber",
0xA432: "LensSpecification",
0xA433: "LensMake",
0xA434: "LensModel",
0xA435: "LensSerialNumber",
0xA460: "CompositeImage",
0xA461: "CompositeImageCount",
0xA462: "CompositeImageExposureTimes",
0xA500: "Gamma",
0xC4A5: "PrintImageMatching",
0xC612: "DNGVersion",
0xC613: "DNGBackwardVersion",
0xC614: "UniqueCameraModel",
0xC615: "LocalizedCameraModel",
0xC616: "CFAPlaneColor",
0xC617: "CFALayout",
0xC618: "LinearizationTable",
0xC619: "BlackLevelRepeatDim",
0xC61A: "BlackLevel",
0xC61B: "BlackLevelDeltaH",
0xC61C: "BlackLevelDeltaV",
0xC61D: "WhiteLevel",
0xC61E: "DefaultScale",
0xC61F: "DefaultCropOrigin",
0xC620: "DefaultCropSize",
0xC621: "ColorMatrix1",
0xC622: "ColorMatrix2",
0xC623: "CameraCalibration1",
0xC624: "CameraCalibration2",
0xC625: "ReductionMatrix1",
0xC626: "ReductionMatrix2",
0xC627: "AnalogBalance",
0xC628: "AsShotNeutral",
0xC629: "AsShotWhiteXY",
0xC62A: "BaselineExposure",
0xC62B: "BaselineNoise",
0xC62C: "BaselineSharpness",
0xC62D: "BayerGreenSplit",
0xC62E: "LinearResponseLimit",
0xC62F: "CameraSerialNumber",
0xC630: "LensInfo",
0xC631: "ChromaBlurRadius",
0xC632: "AntiAliasStrength",
0xC633: "ShadowScale",
0xC634: "DNGPrivateData",
0xC635: "MakerNoteSafety",
0xC65A: "CalibrationIlluminant1",
0xC65B: "CalibrationIlluminant2",
0xC65C: "BestQualityScale",
0xC65D: "RawDataUniqueID",
0xC68B: "OriginalRawFileName",
0xC68C: "OriginalRawFileData",
0xC68D: "ActiveArea",
0xC68E: "MaskedAreas",
0xC68F: "AsShotICCProfile",
0xC690: "AsShotPreProfileMatrix",
0xC691: "CurrentICCProfile",
0xC692: "CurrentPreProfileMatrix",
0xC6BF: "ColorimetricReference",
0xC6F3: "CameraCalibrationSignature",
0xC6F4: "ProfileCalibrationSignature",
0xC6F6: "AsShotProfileName",
0xC6F7: "NoiseReductionApplied",
0xC6F8: "ProfileName",
0xC6F9: "ProfileHueSatMapDims",
0xC6FA: "ProfileHueSatMapData1",
0xC6FB: "ProfileHueSatMapData2",
0xC6FC: "ProfileToneCurve",
0xC6FD: "ProfileEmbedPolicy",
0xC6FE: "ProfileCopyright",
0xC714: "ForwardMatrix1",
0xC715: "ForwardMatrix2",
0xC716: "PreviewApplicationName",
0xC717: "PreviewApplicationVersion",
0xC718: "PreviewSettingsName",
0xC719: "PreviewSettingsDigest",
0xC71A: "PreviewColorSpace",
0xC71B: "PreviewDateTime",
0xC71C: "RawImageDigest",
0xC71D: "OriginalRawFileDigest",
0xC71E: "SubTileBlockSize",
0xC71F: "RowInterleaveFactor",
0xC725: "ProfileLookTableDims",
0xC726: "ProfileLookTableData",
0xC740: "OpcodeList1",
0xC741: "OpcodeList2",
0xC74E: "OpcodeList3",
0xC761: "NoiseProfile",
} }
"""Maps EXIF tags to tag names."""
GPSTAGS = { class GPS(IntEnum):
0: "GPSVersionID", GPSVersionID = 0
1: "GPSLatitudeRef", GPSLatitudeRef = 1
2: "GPSLatitude", GPSLatitude = 2
3: "GPSLongitudeRef", GPSLongitudeRef = 3
4: "GPSLongitude", GPSLongitude = 4
5: "GPSAltitudeRef", GPSAltitudeRef = 5
6: "GPSAltitude", GPSAltitude = 6
7: "GPSTimeStamp", GPSTimeStamp = 7
8: "GPSSatellites", GPSSatellites = 8
9: "GPSStatus", GPSStatus = 9
10: "GPSMeasureMode", GPSMeasureMode = 10
11: "GPSDOP", GPSDOP = 11
12: "GPSSpeedRef", GPSSpeedRef = 12
13: "GPSSpeed", GPSSpeed = 13
14: "GPSTrackRef", GPSTrackRef = 14
15: "GPSTrack", GPSTrack = 15
16: "GPSImgDirectionRef", GPSImgDirectionRef = 16
17: "GPSImgDirection", GPSImgDirection = 17
18: "GPSMapDatum", GPSMapDatum = 18
19: "GPSDestLatitudeRef", GPSDestLatitudeRef = 19
20: "GPSDestLatitude", GPSDestLatitude = 20
21: "GPSDestLongitudeRef", GPSDestLongitudeRef = 21
22: "GPSDestLongitude", GPSDestLongitude = 22
23: "GPSDestBearingRef", GPSDestBearingRef = 23
24: "GPSDestBearing", GPSDestBearing = 24
25: "GPSDestDistanceRef", GPSDestDistanceRef = 25
26: "GPSDestDistance", GPSDestDistance = 26
27: "GPSProcessingMethod", GPSProcessingMethod = 27
28: "GPSAreaInformation", GPSAreaInformation = 28
29: "GPSDateStamp", GPSDateStamp = 29
30: "GPSDifferential", GPSDifferential = 30
31: "GPSHPositioningError", GPSHPositioningError = 31
}
"""Maps EXIF GPS tags to tag names.""" """Maps EXIF GPS tags to tag names."""
GPSTAGS = {i.value: i.name for i in GPS}