UNPKG

4.08 kBJavaScriptView Raw
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://iptc.org/standards/photo-metadata
10 * https://exiftool.org/TagNames/IPTC.html
11 *
12 * Licensed under the MIT license:
13 * https://opensource.org/licenses/MIT
14 */
15
16/* global define, module, require */
17
18;(function (factory) {
19 'use strict'
20 if (typeof define === 'function' && define.amd) {
21 // Register as an anonymous AMD module:
22 define(['./load-image', './load-image-iptc'], factory)
23 } else if (typeof module === 'object' && module.exports) {
24 factory(require('./load-image'), require('./load-image-iptc'))
25 } else {
26 // Browser globals:
27 factory(window.loadImage)
28 }
29})(function (loadImage) {
30 'use strict'
31
32 var IptcMapProto = loadImage.IptcMap.prototype
33
34 IptcMapProto.tags = {
35 0: 'ApplicationRecordVersion',
36 3: 'ObjectTypeReference',
37 4: 'ObjectAttributeReference',
38 5: 'ObjectName',
39 7: 'EditStatus',
40 8: 'EditorialUpdate',
41 10: 'Urgency',
42 12: 'SubjectReference',
43 15: 'Category',
44 20: 'SupplementalCategories',
45 22: 'FixtureIdentifier',
46 25: 'Keywords',
47 26: 'ContentLocationCode',
48 27: 'ContentLocationName',
49 30: 'ReleaseDate',
50 35: 'ReleaseTime',
51 37: 'ExpirationDate',
52 38: 'ExpirationTime',
53 40: 'SpecialInstructions',
54 42: 'ActionAdvised',
55 45: 'ReferenceService',
56 47: 'ReferenceDate',
57 50: 'ReferenceNumber',
58 55: 'DateCreated',
59 60: 'TimeCreated',
60 62: 'DigitalCreationDate',
61 63: 'DigitalCreationTime',
62 65: 'OriginatingProgram',
63 70: 'ProgramVersion',
64 75: 'ObjectCycle',
65 80: 'Byline',
66 85: 'BylineTitle',
67 90: 'City',
68 92: 'Sublocation',
69 95: 'State',
70 100: 'CountryCode',
71 101: 'Country',
72 103: 'OriginalTransmissionReference',
73 105: 'Headline',
74 110: 'Credit',
75 115: 'Source',
76 116: 'CopyrightNotice',
77 118: 'Contact',
78 120: 'Caption',
79 121: 'LocalCaption',
80 122: 'Writer',
81 125: 'RasterizedCaption',
82 130: 'ImageType',
83 131: 'ImageOrientation',
84 135: 'LanguageIdentifier',
85 150: 'AudioType',
86 151: 'AudioSamplingRate',
87 152: 'AudioSamplingResolution',
88 153: 'AudioDuration',
89 154: 'AudioOutcue',
90 184: 'JobID',
91 185: 'MasterDocumentID',
92 186: 'ShortDocumentID',
93 187: 'UniqueDocumentID',
94 188: 'OwnerID',
95 200: 'ObjectPreviewFileFormat',
96 201: 'ObjectPreviewFileVersion',
97 202: 'ObjectPreviewData',
98 221: 'Prefs',
99 225: 'ClassifyState',
100 228: 'SimilarityIndex',
101 230: 'DocumentNotes',
102 231: 'DocumentHistory',
103 232: 'ExifCameraInfo',
104 255: 'CatalogSets'
105 }
106
107 IptcMapProto.stringValues = {
108 10: {
109 0: '0 (reserved)',
110 1: '1 (most urgent)',
111 2: '2',
112 3: '3',
113 4: '4',
114 5: '5 (normal urgency)',
115 6: '6',
116 7: '7',
117 8: '8 (least urgent)',
118 9: '9 (user-defined priority)'
119 },
120 75: {
121 a: 'Morning',
122 b: 'Both Morning and Evening',
123 p: 'Evening'
124 },
125 131: {
126 L: 'Landscape',
127 P: 'Portrait',
128 S: 'Square'
129 }
130 }
131
132 IptcMapProto.getText = function (id) {
133 var value = this.get(id)
134 var tagCode = this.map[id]
135 var stringValue = this.stringValues[tagCode]
136 if (stringValue) return stringValue[value]
137 return String(value)
138 }
139
140 IptcMapProto.getAll = function () {
141 var map = {}
142 var prop
143 var name
144 for (prop in this) {
145 if (Object.prototype.hasOwnProperty.call(this, prop)) {
146 name = this.tags[prop]
147 if (name) map[name] = this.getText(name)
148 }
149 }
150 return map
151 }
152
153 IptcMapProto.getName = function (tagCode) {
154 return this.tags[tagCode]
155 }
156
157 // Extend the map of tag names to tag codes:
158 ;(function () {
159 var tags = IptcMapProto.tags
160 var map = IptcMapProto.map || {}
161 var prop
162 // Map the tag names to tags:
163 for (prop in tags) {
164 if (Object.prototype.hasOwnProperty.call(tags, prop)) {
165 map[tags[prop]] = Number(prop)
166 }
167 }
168 })()
169})