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