Coverage for /usr/lib/python3/dist-packages/PIL/ExifTags.py: 100%

342 statements  

« prev     ^ index     » next       coverage.py v7.9.1, created at 2025-06-14 15:55 +0200

1# 

2# The Python Imaging Library. 

3# $Id$ 

4# 

5# EXIF tags 

6# 

7# Copyright (c) 2003 by Secret Labs AB 

8# 

9# See the README file for information on usage and redistribution. 

10# 

11 

12""" 

13This module provides constants and clear-text names for various 

14well-known EXIF tags. 

15""" 

16from __future__ import annotations 

17 

18from enum import IntEnum 

19 

20 

21class Base(IntEnum): 

22 # possibly incomplete 

23 InteropIndex = 0x0001 

24 ProcessingSoftware = 0x000B 

25 NewSubfileType = 0x00FE 

26 SubfileType = 0x00FF 

27 ImageWidth = 0x0100 

28 ImageLength = 0x0101 

29 BitsPerSample = 0x0102 

30 Compression = 0x0103 

31 PhotometricInterpretation = 0x0106 

32 Thresholding = 0x0107 

33 CellWidth = 0x0108 

34 CellLength = 0x0109 

35 FillOrder = 0x010A 

36 DocumentName = 0x010D 

37 ImageDescription = 0x010E 

38 Make = 0x010F 

39 Model = 0x0110 

40 StripOffsets = 0x0111 

41 Orientation = 0x0112 

42 SamplesPerPixel = 0x0115 

43 RowsPerStrip = 0x0116 

44 StripByteCounts = 0x0117 

45 MinSampleValue = 0x0118 

46 MaxSampleValue = 0x0119 

47 XResolution = 0x011A 

48 YResolution = 0x011B 

49 PlanarConfiguration = 0x011C 

50 PageName = 0x011D 

51 FreeOffsets = 0x0120 

52 FreeByteCounts = 0x0121 

53 GrayResponseUnit = 0x0122 

54 GrayResponseCurve = 0x0123 

55 T4Options = 0x0124 

56 T6Options = 0x0125 

57 ResolutionUnit = 0x0128 

58 PageNumber = 0x0129 

59 TransferFunction = 0x012D 

60 Software = 0x0131 

61 DateTime = 0x0132 

62 Artist = 0x013B 

63 HostComputer = 0x013C 

64 Predictor = 0x013D 

65 WhitePoint = 0x013E 

66 PrimaryChromaticities = 0x013F 

67 ColorMap = 0x0140 

68 HalftoneHints = 0x0141 

69 TileWidth = 0x0142 

70 TileLength = 0x0143 

71 TileOffsets = 0x0144 

72 TileByteCounts = 0x0145 

73 SubIFDs = 0x014A 

74 InkSet = 0x014C 

75 InkNames = 0x014D 

76 NumberOfInks = 0x014E 

77 DotRange = 0x0150 

78 TargetPrinter = 0x0151 

79 ExtraSamples = 0x0152 

80 SampleFormat = 0x0153 

81 SMinSampleValue = 0x0154 

82 SMaxSampleValue = 0x0155 

83 TransferRange = 0x0156 

84 ClipPath = 0x0157 

85 XClipPathUnits = 0x0158 

86 YClipPathUnits = 0x0159 

87 Indexed = 0x015A 

88 JPEGTables = 0x015B 

89 OPIProxy = 0x015F 

90 JPEGProc = 0x0200 

91 JpegIFOffset = 0x0201 

92 JpegIFByteCount = 0x0202 

93 JpegRestartInterval = 0x0203 

94 JpegLosslessPredictors = 0x0205 

95 JpegPointTransforms = 0x0206 

96 JpegQTables = 0x0207 

97 JpegDCTables = 0x0208 

98 JpegACTables = 0x0209 

99 YCbCrCoefficients = 0x0211 

100 YCbCrSubSampling = 0x0212 

101 YCbCrPositioning = 0x0213 

102 ReferenceBlackWhite = 0x0214 

103 XMLPacket = 0x02BC 

104 RelatedImageFileFormat = 0x1000 

105 RelatedImageWidth = 0x1001 

106 RelatedImageLength = 0x1002 

107 Rating = 0x4746 

108 RatingPercent = 0x4749 

109 ImageID = 0x800D 

110 CFARepeatPatternDim = 0x828D 

111 BatteryLevel = 0x828F 

112 Copyright = 0x8298 

113 ExposureTime = 0x829A 

114 FNumber = 0x829D 

115 IPTCNAA = 0x83BB 

116 ImageResources = 0x8649 

117 ExifOffset = 0x8769 

118 InterColorProfile = 0x8773 

119 ExposureProgram = 0x8822 

120 SpectralSensitivity = 0x8824 

121 GPSInfo = 0x8825 

122 ISOSpeedRatings = 0x8827 

123 OECF = 0x8828 

124 Interlace = 0x8829 

125 TimeZoneOffset = 0x882A 

126 SelfTimerMode = 0x882B 

127 SensitivityType = 0x8830 

128 StandardOutputSensitivity = 0x8831 

129 RecommendedExposureIndex = 0x8832 

130 ISOSpeed = 0x8833 

131 ISOSpeedLatitudeyyy = 0x8834 

132 ISOSpeedLatitudezzz = 0x8835 

133 ExifVersion = 0x9000 

134 DateTimeOriginal = 0x9003 

135 DateTimeDigitized = 0x9004 

136 OffsetTime = 0x9010 

137 OffsetTimeOriginal = 0x9011 

138 OffsetTimeDigitized = 0x9012 

139 ComponentsConfiguration = 0x9101 

140 CompressedBitsPerPixel = 0x9102 

141 ShutterSpeedValue = 0x9201 

142 ApertureValue = 0x9202 

143 BrightnessValue = 0x9203 

144 ExposureBiasValue = 0x9204 

145 MaxApertureValue = 0x9205 

146 SubjectDistance = 0x9206 

147 MeteringMode = 0x9207 

148 LightSource = 0x9208 

149 Flash = 0x9209 

150 FocalLength = 0x920A 

151 Noise = 0x920D 

152 ImageNumber = 0x9211 

153 SecurityClassification = 0x9212 

154 ImageHistory = 0x9213 

155 TIFFEPStandardID = 0x9216 

156 MakerNote = 0x927C 

157 UserComment = 0x9286 

158 SubsecTime = 0x9290 

159 SubsecTimeOriginal = 0x9291 

160 SubsecTimeDigitized = 0x9292 

161 AmbientTemperature = 0x9400 

162 Humidity = 0x9401 

163 Pressure = 0x9402 

164 WaterDepth = 0x9403 

165 Acceleration = 0x9404 

166 CameraElevationAngle = 0x9405 

167 XPTitle = 0x9C9B 

168 XPComment = 0x9C9C 

169 XPAuthor = 0x9C9D 

170 XPKeywords = 0x9C9E 

171 XPSubject = 0x9C9F 

172 FlashPixVersion = 0xA000 

173 ColorSpace = 0xA001 

174 ExifImageWidth = 0xA002 

175 ExifImageHeight = 0xA003 

176 RelatedSoundFile = 0xA004 

177 ExifInteroperabilityOffset = 0xA005 

178 FlashEnergy = 0xA20B 

179 SpatialFrequencyResponse = 0xA20C 

180 FocalPlaneXResolution = 0xA20E 

181 FocalPlaneYResolution = 0xA20F 

182 FocalPlaneResolutionUnit = 0xA210 

183 SubjectLocation = 0xA214 

184 ExposureIndex = 0xA215 

185 SensingMethod = 0xA217 

186 FileSource = 0xA300 

187 SceneType = 0xA301 

188 CFAPattern = 0xA302 

189 CustomRendered = 0xA401 

190 ExposureMode = 0xA402 

191 WhiteBalance = 0xA403 

192 DigitalZoomRatio = 0xA404 

193 FocalLengthIn35mmFilm = 0xA405 

194 SceneCaptureType = 0xA406 

195 GainControl = 0xA407 

196 Contrast = 0xA408 

197 Saturation = 0xA409 

198 Sharpness = 0xA40A 

199 DeviceSettingDescription = 0xA40B 

200 SubjectDistanceRange = 0xA40C 

201 ImageUniqueID = 0xA420 

202 CameraOwnerName = 0xA430 

203 BodySerialNumber = 0xA431 

204 LensSpecification = 0xA432 

205 LensMake = 0xA433 

206 LensModel = 0xA434 

207 LensSerialNumber = 0xA435 

208 CompositeImage = 0xA460 

209 CompositeImageCount = 0xA461 

210 CompositeImageExposureTimes = 0xA462 

211 Gamma = 0xA500 

212 PrintImageMatching = 0xC4A5 

213 DNGVersion = 0xC612 

214 DNGBackwardVersion = 0xC613 

215 UniqueCameraModel = 0xC614 

216 LocalizedCameraModel = 0xC615 

217 CFAPlaneColor = 0xC616 

218 CFALayout = 0xC617 

219 LinearizationTable = 0xC618 

220 BlackLevelRepeatDim = 0xC619 

221 BlackLevel = 0xC61A 

222 BlackLevelDeltaH = 0xC61B 

223 BlackLevelDeltaV = 0xC61C 

224 WhiteLevel = 0xC61D 

225 DefaultScale = 0xC61E 

226 DefaultCropOrigin = 0xC61F 

227 DefaultCropSize = 0xC620 

228 ColorMatrix1 = 0xC621 

229 ColorMatrix2 = 0xC622 

230 CameraCalibration1 = 0xC623 

231 CameraCalibration2 = 0xC624 

232 ReductionMatrix1 = 0xC625 

233 ReductionMatrix2 = 0xC626 

234 AnalogBalance = 0xC627 

235 AsShotNeutral = 0xC628 

236 AsShotWhiteXY = 0xC629 

237 BaselineExposure = 0xC62A 

238 BaselineNoise = 0xC62B 

239 BaselineSharpness = 0xC62C 

240 BayerGreenSplit = 0xC62D 

241 LinearResponseLimit = 0xC62E 

242 CameraSerialNumber = 0xC62F 

243 LensInfo = 0xC630 

244 ChromaBlurRadius = 0xC631 

245 AntiAliasStrength = 0xC632 

246 ShadowScale = 0xC633 

247 DNGPrivateData = 0xC634 

248 MakerNoteSafety = 0xC635 

249 CalibrationIlluminant1 = 0xC65A 

250 CalibrationIlluminant2 = 0xC65B 

251 BestQualityScale = 0xC65C 

252 RawDataUniqueID = 0xC65D 

253 OriginalRawFileName = 0xC68B 

254 OriginalRawFileData = 0xC68C 

255 ActiveArea = 0xC68D 

256 MaskedAreas = 0xC68E 

257 AsShotICCProfile = 0xC68F 

258 AsShotPreProfileMatrix = 0xC690 

259 CurrentICCProfile = 0xC691 

260 CurrentPreProfileMatrix = 0xC692 

261 ColorimetricReference = 0xC6BF 

262 CameraCalibrationSignature = 0xC6F3 

263 ProfileCalibrationSignature = 0xC6F4 

264 AsShotProfileName = 0xC6F6 

265 NoiseReductionApplied = 0xC6F7 

266 ProfileName = 0xC6F8 

267 ProfileHueSatMapDims = 0xC6F9 

268 ProfileHueSatMapData1 = 0xC6FA 

269 ProfileHueSatMapData2 = 0xC6FB 

270 ProfileToneCurve = 0xC6FC 

271 ProfileEmbedPolicy = 0xC6FD 

272 ProfileCopyright = 0xC6FE 

273 ForwardMatrix1 = 0xC714 

274 ForwardMatrix2 = 0xC715 

275 PreviewApplicationName = 0xC716 

276 PreviewApplicationVersion = 0xC717 

277 PreviewSettingsName = 0xC718 

278 PreviewSettingsDigest = 0xC719 

279 PreviewColorSpace = 0xC71A 

280 PreviewDateTime = 0xC71B 

281 RawImageDigest = 0xC71C 

282 OriginalRawFileDigest = 0xC71D 

283 SubTileBlockSize = 0xC71E 

284 RowInterleaveFactor = 0xC71F 

285 ProfileLookTableDims = 0xC725 

286 ProfileLookTableData = 0xC726 

287 OpcodeList1 = 0xC740 

288 OpcodeList2 = 0xC741 

289 OpcodeList3 = 0xC74E 

290 NoiseProfile = 0xC761 

291 

292 

293"""Maps EXIF tags to tag names.""" 

294TAGS = { 

295 **{i.value: i.name for i in Base}, 

296 0x920C: "SpatialFrequencyResponse", 

297 0x9214: "SubjectLocation", 

298 0x9215: "ExposureIndex", 

299 0x828E: "CFAPattern", 

300 0x920B: "FlashEnergy", 

301 0x9216: "TIFF/EPStandardID", 

302} 

303 

304 

305class GPS(IntEnum): 

306 GPSVersionID = 0 

307 GPSLatitudeRef = 1 

308 GPSLatitude = 2 

309 GPSLongitudeRef = 3 

310 GPSLongitude = 4 

311 GPSAltitudeRef = 5 

312 GPSAltitude = 6 

313 GPSTimeStamp = 7 

314 GPSSatellites = 8 

315 GPSStatus = 9 

316 GPSMeasureMode = 10 

317 GPSDOP = 11 

318 GPSSpeedRef = 12 

319 GPSSpeed = 13 

320 GPSTrackRef = 14 

321 GPSTrack = 15 

322 GPSImgDirectionRef = 16 

323 GPSImgDirection = 17 

324 GPSMapDatum = 18 

325 GPSDestLatitudeRef = 19 

326 GPSDestLatitude = 20 

327 GPSDestLongitudeRef = 21 

328 GPSDestLongitude = 22 

329 GPSDestBearingRef = 23 

330 GPSDestBearing = 24 

331 GPSDestDistanceRef = 25 

332 GPSDestDistance = 26 

333 GPSProcessingMethod = 27 

334 GPSAreaInformation = 28 

335 GPSDateStamp = 29 

336 GPSDifferential = 30 

337 GPSHPositioningError = 31 

338 

339 

340"""Maps EXIF GPS tags to tag names.""" 

341GPSTAGS = {i.value: i.name for i in GPS} 

342 

343 

344class Interop(IntEnum): 

345 InteropIndex = 1 

346 InteropVersion = 2 

347 RelatedImageFileFormat = 4096 

348 RelatedImageWidth = 4097 

349 RleatedImageHeight = 4098 

350 

351 

352class IFD(IntEnum): 

353 Exif = 34665 

354 GPSInfo = 34853 

355 Makernote = 37500 

356 Interop = 40965 

357 IFD1 = -1 

358 

359 

360class LightSource(IntEnum): 

361 Unknown = 0 

362 Daylight = 1 

363 Fluorescent = 2 

364 Tungsten = 3 

365 Flash = 4 

366 Fine = 9 

367 Cloudy = 10 

368 Shade = 11 

369 DaylightFluorescent = 12 

370 DayWhiteFluorescent = 13 

371 CoolWhiteFluorescent = 14 

372 WhiteFluorescent = 15 

373 StandardLightA = 17 

374 StandardLightB = 18 

375 StandardLightC = 19 

376 D55 = 20 

377 D65 = 21 

378 D75 = 22 

379 D50 = 23 

380 ISO = 24 

381 Other = 255