load-image-exif-map.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. /*
  2. * JavaScript Load Image Exif Map
  3. * https://github.com/blueimp/JavaScript-Load-Image
  4. *
  5. * Copyright 2013, Sebastian Tschan
  6. * https://blueimp.net
  7. *
  8. * Exif tags mapping based on
  9. * https://github.com/jseidelin/exif-js
  10. *
  11. * Licensed under the MIT license:
  12. * http://www.opensource.org/licenses/MIT
  13. */
  14. /*global define, module, require, window */
  15. ;(function (factory) {
  16. 'use strict'
  17. if (typeof define === 'function' && define.amd) {
  18. // Register as an anonymous AMD module:
  19. define(['./load-image', './load-image-exif'], factory)
  20. } else if (typeof module === 'object' && module.exports) {
  21. factory(require('./load-image'), require('./load-image-exif'))
  22. } else {
  23. // Browser globals:
  24. factory(window.loadImage)
  25. }
  26. }(function (loadImage) {
  27. 'use strict'
  28. loadImage.ExifMap.prototype.tags = {
  29. // =================
  30. // TIFF tags (IFD0):
  31. // =================
  32. 0x0100: 'ImageWidth',
  33. 0x0101: 'ImageHeight',
  34. 0x8769: 'ExifIFDPointer',
  35. 0x8825: 'GPSInfoIFDPointer',
  36. 0xA005: 'InteroperabilityIFDPointer',
  37. 0x0102: 'BitsPerSample',
  38. 0x0103: 'Compression',
  39. 0x0106: 'PhotometricInterpretation',
  40. 0x0112: 'Orientation',
  41. 0x0115: 'SamplesPerPixel',
  42. 0x011C: 'PlanarConfiguration',
  43. 0x0212: 'YCbCrSubSampling',
  44. 0x0213: 'YCbCrPositioning',
  45. 0x011A: 'XResolution',
  46. 0x011B: 'YResolution',
  47. 0x0128: 'ResolutionUnit',
  48. 0x0111: 'StripOffsets',
  49. 0x0116: 'RowsPerStrip',
  50. 0x0117: 'StripByteCounts',
  51. 0x0201: 'JPEGInterchangeFormat',
  52. 0x0202: 'JPEGInterchangeFormatLength',
  53. 0x012D: 'TransferFunction',
  54. 0x013E: 'WhitePoint',
  55. 0x013F: 'PrimaryChromaticities',
  56. 0x0211: 'YCbCrCoefficients',
  57. 0x0214: 'ReferenceBlackWhite',
  58. 0x0132: 'DateTime',
  59. 0x010E: 'ImageDescription',
  60. 0x010F: 'Make',
  61. 0x0110: 'Model',
  62. 0x0131: 'Software',
  63. 0x013B: 'Artist',
  64. 0x8298: 'Copyright',
  65. // ==================
  66. // Exif Sub IFD tags:
  67. // ==================
  68. 0x9000: 'ExifVersion', // EXIF version
  69. 0xA000: 'FlashpixVersion', // Flashpix format version
  70. 0xA001: 'ColorSpace', // Color space information tag
  71. 0xA002: 'PixelXDimension', // Valid width of meaningful image
  72. 0xA003: 'PixelYDimension', // Valid height of meaningful image
  73. 0xA500: 'Gamma',
  74. 0x9101: 'ComponentsConfiguration', // Information about channels
  75. 0x9102: 'CompressedBitsPerPixel', // Compressed bits per pixel
  76. 0x927C: 'MakerNote', // Any desired information written by the manufacturer
  77. 0x9286: 'UserComment', // Comments by user
  78. 0xA004: 'RelatedSoundFile', // Name of related sound file
  79. 0x9003: 'DateTimeOriginal', // Date and time when the original image was generated
  80. 0x9004: 'DateTimeDigitized', // Date and time when the image was stored digitally
  81. 0x9290: 'SubSecTime', // Fractions of seconds for DateTime
  82. 0x9291: 'SubSecTimeOriginal', // Fractions of seconds for DateTimeOriginal
  83. 0x9292: 'SubSecTimeDigitized', // Fractions of seconds for DateTimeDigitized
  84. 0x829A: 'ExposureTime', // Exposure time (in seconds)
  85. 0x829D: 'FNumber',
  86. 0x8822: 'ExposureProgram', // Exposure program
  87. 0x8824: 'SpectralSensitivity', // Spectral sensitivity
  88. 0x8827: 'PhotographicSensitivity', // EXIF 2.3, ISOSpeedRatings in EXIF 2.2
  89. 0x8828: 'OECF', // Optoelectric conversion factor
  90. 0x8830: 'SensitivityType',
  91. 0x8831: 'StandardOutputSensitivity',
  92. 0x8832: 'RecommendedExposureIndex',
  93. 0x8833: 'ISOSpeed',
  94. 0x8834: 'ISOSpeedLatitudeyyy',
  95. 0x8835: 'ISOSpeedLatitudezzz',
  96. 0x9201: 'ShutterSpeedValue', // Shutter speed
  97. 0x9202: 'ApertureValue', // Lens aperture
  98. 0x9203: 'BrightnessValue', // Value of brightness
  99. 0x9204: 'ExposureBias', // Exposure bias
  100. 0x9205: 'MaxApertureValue', // Smallest F number of lens
  101. 0x9206: 'SubjectDistance', // Distance to subject in meters
  102. 0x9207: 'MeteringMode', // Metering mode
  103. 0x9208: 'LightSource', // Kind of light source
  104. 0x9209: 'Flash', // Flash status
  105. 0x9214: 'SubjectArea', // Location and area of main subject
  106. 0x920A: 'FocalLength', // Focal length of the lens in mm
  107. 0xA20B: 'FlashEnergy', // Strobe energy in BCPS
  108. 0xA20C: 'SpatialFrequencyResponse',
  109. 0xA20E: 'FocalPlaneXResolution', // Number of pixels in width direction per FPRUnit
  110. 0xA20F: 'FocalPlaneYResolution', // Number of pixels in height direction per FPRUnit
  111. 0xA210: 'FocalPlaneResolutionUnit', // Unit for measuring the focal plane resolution
  112. 0xA214: 'SubjectLocation', // Location of subject in image
  113. 0xA215: 'ExposureIndex', // Exposure index selected on camera
  114. 0xA217: 'SensingMethod', // Image sensor type
  115. 0xA300: 'FileSource', // Image source (3 == DSC)
  116. 0xA301: 'SceneType', // Scene type (1 == directly photographed)
  117. 0xA302: 'CFAPattern', // Color filter array geometric pattern
  118. 0xA401: 'CustomRendered', // Special processing
  119. 0xA402: 'ExposureMode', // Exposure mode
  120. 0xA403: 'WhiteBalance', // 1 = auto white balance, 2 = manual
  121. 0xA404: 'DigitalZoomRatio', // Digital zoom ratio
  122. 0xA405: 'FocalLengthIn35mmFilm',
  123. 0xA406: 'SceneCaptureType', // Type of scene
  124. 0xA407: 'GainControl', // Degree of overall image gain adjustment
  125. 0xA408: 'Contrast', // Direction of contrast processing applied by camera
  126. 0xA409: 'Saturation', // Direction of saturation processing applied by camera
  127. 0xA40A: 'Sharpness', // Direction of sharpness processing applied by camera
  128. 0xA40B: 'DeviceSettingDescription',
  129. 0xA40C: 'SubjectDistanceRange', // Distance to subject
  130. 0xA420: 'ImageUniqueID', // Identifier assigned uniquely to each image
  131. 0xA430: 'CameraOwnerName',
  132. 0xA431: 'BodySerialNumber',
  133. 0xA432: 'LensSpecification',
  134. 0xA433: 'LensMake',
  135. 0xA434: 'LensModel',
  136. 0xA435: 'LensSerialNumber',
  137. // ==============
  138. // GPS Info tags:
  139. // ==============
  140. 0x0000: 'GPSVersionID',
  141. 0x0001: 'GPSLatitudeRef',
  142. 0x0002: 'GPSLatitude',
  143. 0x0003: 'GPSLongitudeRef',
  144. 0x0004: 'GPSLongitude',
  145. 0x0005: 'GPSAltitudeRef',
  146. 0x0006: 'GPSAltitude',
  147. 0x0007: 'GPSTimeStamp',
  148. 0x0008: 'GPSSatellites',
  149. 0x0009: 'GPSStatus',
  150. 0x000A: 'GPSMeasureMode',
  151. 0x000B: 'GPSDOP',
  152. 0x000C: 'GPSSpeedRef',
  153. 0x000D: 'GPSSpeed',
  154. 0x000E: 'GPSTrackRef',
  155. 0x000F: 'GPSTrack',
  156. 0x0010: 'GPSImgDirectionRef',
  157. 0x0011: 'GPSImgDirection',
  158. 0x0012: 'GPSMapDatum',
  159. 0x0013: 'GPSDestLatitudeRef',
  160. 0x0014: 'GPSDestLatitude',
  161. 0x0015: 'GPSDestLongitudeRef',
  162. 0x0016: 'GPSDestLongitude',
  163. 0x0017: 'GPSDestBearingRef',
  164. 0x0018: 'GPSDestBearing',
  165. 0x0019: 'GPSDestDistanceRef',
  166. 0x001A: 'GPSDestDistance',
  167. 0x001B: 'GPSProcessingMethod',
  168. 0x001C: 'GPSAreaInformation',
  169. 0x001D: 'GPSDateStamp',
  170. 0x001E: 'GPSDifferential',
  171. 0x001F: 'GPSHPositioningError'
  172. }
  173. loadImage.ExifMap.prototype.stringValues = {
  174. ExposureProgram: {
  175. 0: 'Undefined',
  176. 1: 'Manual',
  177. 2: 'Normal program',
  178. 3: 'Aperture priority',
  179. 4: 'Shutter priority',
  180. 5: 'Creative program',
  181. 6: 'Action program',
  182. 7: 'Portrait mode',
  183. 8: 'Landscape mode'
  184. },
  185. MeteringMode: {
  186. 0: 'Unknown',
  187. 1: 'Average',
  188. 2: 'CenterWeightedAverage',
  189. 3: 'Spot',
  190. 4: 'MultiSpot',
  191. 5: 'Pattern',
  192. 6: 'Partial',
  193. 255: 'Other'
  194. },
  195. LightSource: {
  196. 0: 'Unknown',
  197. 1: 'Daylight',
  198. 2: 'Fluorescent',
  199. 3: 'Tungsten (incandescent light)',
  200. 4: 'Flash',
  201. 9: 'Fine weather',
  202. 10: 'Cloudy weather',
  203. 11: 'Shade',
  204. 12: 'Daylight fluorescent (D 5700 - 7100K)',
  205. 13: 'Day white fluorescent (N 4600 - 5400K)',
  206. 14: 'Cool white fluorescent (W 3900 - 4500K)',
  207. 15: 'White fluorescent (WW 3200 - 3700K)',
  208. 17: 'Standard light A',
  209. 18: 'Standard light B',
  210. 19: 'Standard light C',
  211. 20: 'D55',
  212. 21: 'D65',
  213. 22: 'D75',
  214. 23: 'D50',
  215. 24: 'ISO studio tungsten',
  216. 255: 'Other'
  217. },
  218. Flash: {
  219. 0x0000: 'Flash did not fire',
  220. 0x0001: 'Flash fired',
  221. 0x0005: 'Strobe return light not detected',
  222. 0x0007: 'Strobe return light detected',
  223. 0x0009: 'Flash fired, compulsory flash mode',
  224. 0x000D: 'Flash fired, compulsory flash mode, return light not detected',
  225. 0x000F: 'Flash fired, compulsory flash mode, return light detected',
  226. 0x0010: 'Flash did not fire, compulsory flash mode',
  227. 0x0018: 'Flash did not fire, auto mode',
  228. 0x0019: 'Flash fired, auto mode',
  229. 0x001D: 'Flash fired, auto mode, return light not detected',
  230. 0x001F: 'Flash fired, auto mode, return light detected',
  231. 0x0020: 'No flash function',
  232. 0x0041: 'Flash fired, red-eye reduction mode',
  233. 0x0045: 'Flash fired, red-eye reduction mode, return light not detected',
  234. 0x0047: 'Flash fired, red-eye reduction mode, return light detected',
  235. 0x0049: 'Flash fired, compulsory flash mode, red-eye reduction mode',
  236. 0x004D: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected',
  237. 0x004F: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light detected',
  238. 0x0059: 'Flash fired, auto mode, red-eye reduction mode',
  239. 0x005D: 'Flash fired, auto mode, return light not detected, red-eye reduction mode',
  240. 0x005F: 'Flash fired, auto mode, return light detected, red-eye reduction mode'
  241. },
  242. SensingMethod: {
  243. 1: 'Undefined',
  244. 2: 'One-chip color area sensor',
  245. 3: 'Two-chip color area sensor',
  246. 4: 'Three-chip color area sensor',
  247. 5: 'Color sequential area sensor',
  248. 7: 'Trilinear sensor',
  249. 8: 'Color sequential linear sensor'
  250. },
  251. SceneCaptureType: {
  252. 0: 'Standard',
  253. 1: 'Landscape',
  254. 2: 'Portrait',
  255. 3: 'Night scene'
  256. },
  257. SceneType: {
  258. 1: 'Directly photographed'
  259. },
  260. CustomRendered: {
  261. 0: 'Normal process',
  262. 1: 'Custom process'
  263. },
  264. WhiteBalance: {
  265. 0: 'Auto white balance',
  266. 1: 'Manual white balance'
  267. },
  268. GainControl: {
  269. 0: 'None',
  270. 1: 'Low gain up',
  271. 2: 'High gain up',
  272. 3: 'Low gain down',
  273. 4: 'High gain down'
  274. },
  275. Contrast: {
  276. 0: 'Normal',
  277. 1: 'Soft',
  278. 2: 'Hard'
  279. },
  280. Saturation: {
  281. 0: 'Normal',
  282. 1: 'Low saturation',
  283. 2: 'High saturation'
  284. },
  285. Sharpness: {
  286. 0: 'Normal',
  287. 1: 'Soft',
  288. 2: 'Hard'
  289. },
  290. SubjectDistanceRange: {
  291. 0: 'Unknown',
  292. 1: 'Macro',
  293. 2: 'Close view',
  294. 3: 'Distant view'
  295. },
  296. FileSource: {
  297. 3: 'DSC'
  298. },
  299. ComponentsConfiguration: {
  300. 0: '',
  301. 1: 'Y',
  302. 2: 'Cb',
  303. 3: 'Cr',
  304. 4: 'R',
  305. 5: 'G',
  306. 6: 'B'
  307. },
  308. Orientation: {
  309. 1: 'top-left',
  310. 2: 'top-right',
  311. 3: 'bottom-right',
  312. 4: 'bottom-left',
  313. 5: 'left-top',
  314. 6: 'right-top',
  315. 7: 'right-bottom',
  316. 8: 'left-bottom'
  317. }
  318. }
  319. loadImage.ExifMap.prototype.getText = function (id) {
  320. var value = this.get(id)
  321. switch (id) {
  322. case 'LightSource':
  323. case 'Flash':
  324. case 'MeteringMode':
  325. case 'ExposureProgram':
  326. case 'SensingMethod':
  327. case 'SceneCaptureType':
  328. case 'SceneType':
  329. case 'CustomRendered':
  330. case 'WhiteBalance':
  331. case 'GainControl':
  332. case 'Contrast':
  333. case 'Saturation':
  334. case 'Sharpness':
  335. case 'SubjectDistanceRange':
  336. case 'FileSource':
  337. case 'Orientation':
  338. return this.stringValues[id][value]
  339. case 'ExifVersion':
  340. case 'FlashpixVersion':
  341. return String.fromCharCode(value[0], value[1], value[2], value[3])
  342. case 'ComponentsConfiguration':
  343. return this.stringValues[id][value[0]] +
  344. this.stringValues[id][value[1]] +
  345. this.stringValues[id][value[2]] +
  346. this.stringValues[id][value[3]]
  347. case 'GPSVersionID':
  348. return value[0] + '.' + value[1] + '.' + value[2] + '.' + value[3]
  349. }
  350. return String(value)
  351. }
  352. ;(function (exifMapPrototype) {
  353. var tags = exifMapPrototype.tags
  354. var map = exifMapPrototype.map
  355. var prop
  356. // Map the tag names to tags:
  357. for (prop in tags) {
  358. if (tags.hasOwnProperty(prop)) {
  359. map[tags[prop]] = prop
  360. }
  361. }
  362. }(loadImage.ExifMap.prototype))
  363. loadImage.ExifMap.prototype.getAll = function () {
  364. var map = {}
  365. var prop
  366. var id
  367. for (prop in this) {
  368. if (this.hasOwnProperty(prop)) {
  369. id = this.tags[prop]
  370. if (id) {
  371. map[id] = this.getText(id)
  372. }
  373. }
  374. }
  375. return map
  376. }
  377. }))