load-image-iptc-map.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * JavaScript Load Image IPTC Map
  3. * https://github.com/blueimp/JavaScript-Load-Image
  4. *
  5. * Copyright 2013, Sebastian Tschan
  6. * Copyright 2018, Dave Bevan
  7. *
  8. * IPTC tags mapping based on
  9. * https://github.com/jseidelin/exif-js
  10. * https://iptc.org/standards/photo-metadata
  11. * http://www.iptc.org/std/IIM/4.1/specification/IIMV4.1.pdf
  12. *
  13. * Licensed under the MIT license:
  14. * https://opensource.org/licenses/MIT
  15. */
  16. /* global define, module, require */
  17. ;(function(factory) {
  18. 'use strict'
  19. if (typeof define === 'function' && define.amd) {
  20. // Register as an anonymous AMD module:
  21. define(['./load-image', './load-image-iptc'], factory)
  22. } else if (typeof module === 'object' && module.exports) {
  23. factory(require('./load-image'), require('./load-image-iptc'))
  24. } else {
  25. // Browser globals:
  26. factory(window.loadImage)
  27. }
  28. })(function(loadImage) {
  29. 'use strict'
  30. loadImage.IptcMap.prototype.tags = {
  31. // ==========
  32. // IPTC tags:
  33. // ==========
  34. 0x03: 'ObjectType',
  35. 0x04: 'ObjectAttribute',
  36. 0x05: 'ObjectName',
  37. 0x07: 'EditStatus',
  38. 0x08: 'EditorialUpdate',
  39. 0x0a: 'Urgency',
  40. 0x0c: 'SubjectRef',
  41. 0x0f: 'Category',
  42. 0x14: 'SupplCategory',
  43. 0x16: 'FixtureID',
  44. 0x19: 'Keywords',
  45. 0x1a: 'ContentLocCode',
  46. 0x1b: 'ContentLocName',
  47. 0x1e: 'ReleaseDate',
  48. 0x23: 'ReleaseTime',
  49. 0x25: 'ExpirationDate',
  50. 0x26: 'ExpirationTime',
  51. 0x28: 'SpecialInstructions',
  52. 0x2a: 'ActionAdvised',
  53. 0x2d: 'RefService',
  54. 0x2f: 'RefDate',
  55. 0x32: 'RefNumber',
  56. 0x37: 'DateCreated',
  57. 0x3c: 'TimeCreated',
  58. 0x3e: 'DigitalCreationDate',
  59. 0x3f: 'DigitalCreationTime',
  60. 0x41: 'OriginatingProgram',
  61. 0x46: 'ProgramVersion',
  62. 0x4b: 'ObjectCycle',
  63. 0x50: 'Byline',
  64. 0x55: 'BylineTitle',
  65. 0x5a: 'City',
  66. 0x5c: 'Sublocation',
  67. 0x5f: 'State',
  68. 0x64: 'CountryCode',
  69. 0x65: 'CountryName',
  70. 0x67: 'OrigTransRef',
  71. 0x69: 'Headline',
  72. 0x6e: 'Credit',
  73. 0x73: 'Source',
  74. 0x74: 'CopyrightNotice',
  75. 0x76: 'Contact',
  76. 0x78: 'Caption',
  77. 0x7a: 'WriterEditor',
  78. 0x82: 'ImageType',
  79. 0x83: 'ImageOrientation',
  80. 0x87: 'LanguageID'
  81. // We don't record these tags:
  82. //
  83. // 0x00: 'RecordVersion',
  84. // 0x7d: 'RasterizedCaption',
  85. // 0x96: 'AudioType',
  86. // 0x97: 'AudioSamplingRate',
  87. // 0x98: 'AudioSamplingRes',
  88. // 0x99: 'AudioDuration',
  89. // 0x9a: 'AudioOutcue',
  90. // 0xc8: 'PreviewFileFormat',
  91. // 0xc9: 'PreviewFileFormatVer',
  92. // 0xca: 'PreviewData'
  93. }
  94. loadImage.IptcMap.prototype.getText = function(id) {
  95. var value = this.get(id)
  96. return String(value)
  97. }
  98. ;(function(iptcMapPrototype) {
  99. var tags = iptcMapPrototype.tags
  100. var map = iptcMapPrototype.map || {}
  101. var prop
  102. // Map the tag names to tags:
  103. for (prop in tags) {
  104. if (Object.prototype.hasOwnProperty.call(tags, prop)) {
  105. map[tags[prop]] = prop
  106. }
  107. }
  108. })(loadImage.IptcMap.prototype)
  109. loadImage.IptcMap.prototype.getAll = function() {
  110. var map = {}
  111. var prop
  112. var id
  113. for (prop in this) {
  114. if (Object.prototype.hasOwnProperty.call(this, prop)) {
  115. id = this.tags[prop]
  116. if (id) {
  117. map[id] = this.getText(id)
  118. }
  119. }
  120. }
  121. return map
  122. }
  123. })