Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

421 rader
14 KiB

  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. * https://opensource.org/licenses/MIT
  13. */
  14. /* global define, module, require */
  15. ;(function (factory) {
  16. 'use strict'
  17. if (typeof define === 'function' && define.amd) {
  18. // Register as an anonymous AMD module:
  19. define(['jquery/fileUploader/vendor/blueimp-load-image/js/load-image', 'jquery/fileUploader/vendor/blueimp-load-image/js/load-image-exif'], factory)
  20. } else if (typeof module === 'object' && module.exports) {
  21. factory(require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image'), require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image-exif'))
  22. } else {
  23. // Browser globals:
  24. factory(window.loadImage)
  25. }
  26. })(function (loadImage) {
  27. 'use strict'
  28. var ExifMapProto = loadImage.ExifMap.prototype
  29. ExifMapProto.tags = {
  30. // =================
  31. // TIFF tags (IFD0):
  32. // =================
  33. 0x0100: 'ImageWidth',
  34. 0x0101: 'ImageHeight',
  35. 0x0102: 'BitsPerSample',
  36. 0x0103: 'Compression',
  37. 0x0106: 'PhotometricInterpretation',
  38. 0x0112: 'Orientation',
  39. 0x0115: 'SamplesPerPixel',
  40. 0x011c: 'PlanarConfiguration',
  41. 0x0212: 'YCbCrSubSampling',
  42. 0x0213: 'YCbCrPositioning',
  43. 0x011a: 'XResolution',
  44. 0x011b: 'YResolution',
  45. 0x0128: 'ResolutionUnit',
  46. 0x0111: 'StripOffsets',
  47. 0x0116: 'RowsPerStrip',
  48. 0x0117: 'StripByteCounts',
  49. 0x0201: 'JPEGInterchangeFormat',
  50. 0x0202: 'JPEGInterchangeFormatLength',
  51. 0x012d: 'TransferFunction',
  52. 0x013e: 'WhitePoint',
  53. 0x013f: 'PrimaryChromaticities',
  54. 0x0211: 'YCbCrCoefficients',
  55. 0x0214: 'ReferenceBlackWhite',
  56. 0x0132: 'DateTime',
  57. 0x010e: 'ImageDescription',
  58. 0x010f: 'Make',
  59. 0x0110: 'Model',
  60. 0x0131: 'Software',
  61. 0x013b: 'Artist',
  62. 0x8298: 'Copyright',
  63. 0x8769: {
  64. // ExifIFDPointer
  65. 0x9000: 'ExifVersion', // EXIF version
  66. 0xa000: 'FlashpixVersion', // Flashpix format version
  67. 0xa001: 'ColorSpace', // Color space information tag
  68. 0xa002: 'PixelXDimension', // Valid width of meaningful image
  69. 0xa003: 'PixelYDimension', // Valid height of meaningful image
  70. 0xa500: 'Gamma',
  71. 0x9101: 'ComponentsConfiguration', // Information about channels
  72. 0x9102: 'CompressedBitsPerPixel', // Compressed bits per pixel
  73. 0x927c: 'MakerNote', // Any desired information written by the manufacturer
  74. 0x9286: 'UserComment', // Comments by user
  75. 0xa004: 'RelatedSoundFile', // Name of related sound file
  76. 0x9003: 'DateTimeOriginal', // Date and time when the original image was generated
  77. 0x9004: 'DateTimeDigitized', // Date and time when the image was stored digitally
  78. 0x9010: 'OffsetTime', // Time zone when the image file was last changed
  79. 0x9011: 'OffsetTimeOriginal', // Time zone when the image was stored digitally
  80. 0x9012: 'OffsetTimeDigitized', // Time zone 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. 0x8825: {
  139. // GPSInfoIFDPointer
  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. 0xa005: {
  174. // InteroperabilityIFDPointer
  175. 0x0001: 'InteroperabilityIndex'
  176. }
  177. }
  178. // IFD1 directory can contain any IFD0 tags:
  179. ExifMapProto.tags.ifd1 = ExifMapProto.tags
  180. ExifMapProto.stringValues = {
  181. ExposureProgram: {
  182. 0: 'Undefined',
  183. 1: 'Manual',
  184. 2: 'Normal program',
  185. 3: 'Aperture priority',
  186. 4: 'Shutter priority',
  187. 5: 'Creative program',
  188. 6: 'Action program',
  189. 7: 'Portrait mode',
  190. 8: 'Landscape mode'
  191. },
  192. MeteringMode: {
  193. 0: 'Unknown',
  194. 1: 'Average',
  195. 2: 'CenterWeightedAverage',
  196. 3: 'Spot',
  197. 4: 'MultiSpot',
  198. 5: 'Pattern',
  199. 6: 'Partial',
  200. 255: 'Other'
  201. },
  202. LightSource: {
  203. 0: 'Unknown',
  204. 1: 'Daylight',
  205. 2: 'Fluorescent',
  206. 3: 'Tungsten (incandescent light)',
  207. 4: 'Flash',
  208. 9: 'Fine weather',
  209. 10: 'Cloudy weather',
  210. 11: 'Shade',
  211. 12: 'Daylight fluorescent (D 5700 - 7100K)',
  212. 13: 'Day white fluorescent (N 4600 - 5400K)',
  213. 14: 'Cool white fluorescent (W 3900 - 4500K)',
  214. 15: 'White fluorescent (WW 3200 - 3700K)',
  215. 17: 'Standard light A',
  216. 18: 'Standard light B',
  217. 19: 'Standard light C',
  218. 20: 'D55',
  219. 21: 'D65',
  220. 22: 'D75',
  221. 23: 'D50',
  222. 24: 'ISO studio tungsten',
  223. 255: 'Other'
  224. },
  225. Flash: {
  226. 0x0000: 'Flash did not fire',
  227. 0x0001: 'Flash fired',
  228. 0x0005: 'Strobe return light not detected',
  229. 0x0007: 'Strobe return light detected',
  230. 0x0009: 'Flash fired, compulsory flash mode',
  231. 0x000d: 'Flash fired, compulsory flash mode, return light not detected',
  232. 0x000f: 'Flash fired, compulsory flash mode, return light detected',
  233. 0x0010: 'Flash did not fire, compulsory flash mode',
  234. 0x0018: 'Flash did not fire, auto mode',
  235. 0x0019: 'Flash fired, auto mode',
  236. 0x001d: 'Flash fired, auto mode, return light not detected',
  237. 0x001f: 'Flash fired, auto mode, return light detected',
  238. 0x0020: 'No flash function',
  239. 0x0041: 'Flash fired, red-eye reduction mode',
  240. 0x0045: 'Flash fired, red-eye reduction mode, return light not detected',
  241. 0x0047: 'Flash fired, red-eye reduction mode, return light detected',
  242. 0x0049: 'Flash fired, compulsory flash mode, red-eye reduction mode',
  243. 0x004d: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected',
  244. 0x004f: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light detected',
  245. 0x0059: 'Flash fired, auto mode, red-eye reduction mode',
  246. 0x005d: 'Flash fired, auto mode, return light not detected, red-eye reduction mode',
  247. 0x005f: 'Flash fired, auto mode, return light detected, red-eye reduction mode'
  248. },
  249. SensingMethod: {
  250. 1: 'Undefined',
  251. 2: 'One-chip color area sensor',
  252. 3: 'Two-chip color area sensor',
  253. 4: 'Three-chip color area sensor',
  254. 5: 'Color sequential area sensor',
  255. 7: 'Trilinear sensor',
  256. 8: 'Color sequential linear sensor'
  257. },
  258. SceneCaptureType: {
  259. 0: 'Standard',
  260. 1: 'Landscape',
  261. 2: 'Portrait',
  262. 3: 'Night scene'
  263. },
  264. SceneType: {
  265. 1: 'Directly photographed'
  266. },
  267. CustomRendered: {
  268. 0: 'Normal process',
  269. 1: 'Custom process'
  270. },
  271. WhiteBalance: {
  272. 0: 'Auto white balance',
  273. 1: 'Manual white balance'
  274. },
  275. GainControl: {
  276. 0: 'None',
  277. 1: 'Low gain up',
  278. 2: 'High gain up',
  279. 3: 'Low gain down',
  280. 4: 'High gain down'
  281. },
  282. Contrast: {
  283. 0: 'Normal',
  284. 1: 'Soft',
  285. 2: 'Hard'
  286. },
  287. Saturation: {
  288. 0: 'Normal',
  289. 1: 'Low saturation',
  290. 2: 'High saturation'
  291. },
  292. Sharpness: {
  293. 0: 'Normal',
  294. 1: 'Soft',
  295. 2: 'Hard'
  296. },
  297. SubjectDistanceRange: {
  298. 0: 'Unknown',
  299. 1: 'Macro',
  300. 2: 'Close view',
  301. 3: 'Distant view'
  302. },
  303. FileSource: {
  304. 3: 'DSC'
  305. },
  306. ComponentsConfiguration: {
  307. 0: '',
  308. 1: 'Y',
  309. 2: 'Cb',
  310. 3: 'Cr',
  311. 4: 'R',
  312. 5: 'G',
  313. 6: 'B'
  314. },
  315. Orientation: {
  316. 1: 'Original',
  317. 2: 'Horizontal flip',
  318. 3: 'Rotate 180° CCW',
  319. 4: 'Vertical flip',
  320. 5: 'Vertical flip + Rotate 90° CW',
  321. 6: 'Rotate 90° CW',
  322. 7: 'Horizontal flip + Rotate 90° CW',
  323. 8: 'Rotate 90° CCW'
  324. }
  325. }
  326. ExifMapProto.getText = function (name) {
  327. var value = this.get(name)
  328. switch (name) {
  329. case 'LightSource':
  330. case 'Flash':
  331. case 'MeteringMode':
  332. case 'ExposureProgram':
  333. case 'SensingMethod':
  334. case 'SceneCaptureType':
  335. case 'SceneType':
  336. case 'CustomRendered':
  337. case 'WhiteBalance':
  338. case 'GainControl':
  339. case 'Contrast':
  340. case 'Saturation':
  341. case 'Sharpness':
  342. case 'SubjectDistanceRange':
  343. case 'FileSource':
  344. case 'Orientation':
  345. return this.stringValues[name][value]
  346. case 'ExifVersion':
  347. case 'FlashpixVersion':
  348. if (!value) return
  349. return String.fromCharCode(value[0], value[1], value[2], value[3])
  350. case 'ComponentsConfiguration':
  351. if (!value) return
  352. return (
  353. this.stringValues[name][value[0]] +
  354. this.stringValues[name][value[1]] +
  355. this.stringValues[name][value[2]] +
  356. this.stringValues[name][value[3]]
  357. )
  358. case 'GPSVersionID':
  359. if (!value) return
  360. return value[0] + '.' + value[1] + '.' + value[2] + '.' + value[3]
  361. }
  362. return String(value)
  363. }
  364. ExifMapProto.getAll = function () {
  365. var map = {}
  366. var prop
  367. var obj
  368. var name
  369. for (prop in this) {
  370. if (Object.prototype.hasOwnProperty.call(this, prop)) {
  371. obj = this[prop]
  372. if (obj && obj.getAll) {
  373. map[this.ifds[prop].name] = obj.getAll()
  374. } else {
  375. name = this.tags[prop]
  376. if (name) map[name] = this.getText(name)
  377. }
  378. }
  379. }
  380. return map
  381. }
  382. ExifMapProto.getName = function (tagCode) {
  383. var name = this.tags[tagCode]
  384. if (typeof name === 'object') return this.ifds[tagCode].name
  385. return name
  386. }
  387. // Extend the map of tag names to tag codes:
  388. ;(function () {
  389. var tags = ExifMapProto.tags
  390. var prop
  391. var ifd
  392. var subTags
  393. // Map the tag names to tags:
  394. for (prop in tags) {
  395. if (Object.prototype.hasOwnProperty.call(tags, prop)) {
  396. ifd = ExifMapProto.ifds[prop]
  397. if (ifd) {
  398. subTags = tags[prop]
  399. for (prop in subTags) {
  400. if (Object.prototype.hasOwnProperty.call(subTags, prop)) {
  401. ifd.map[subTags[prop]] = Number(prop)
  402. }
  403. }
  404. } else {
  405. ExifMapProto.map[tags[prop]] = Number(prop)
  406. }
  407. }
  408. }
  409. })()
  410. })