exifreader 4.53.0 → 4.55.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/README.md +404 -33
  2. package/bin/analyze.js +139 -9
  3. package/bin/build-pages.js +21 -35
  4. package/bin/cli.js +81 -13
  5. package/bin/generate-tag-modules.js +287 -0
  6. package/dist/exif-reader.js +1 -1
  7. package/dist/exif-reader.js.map +1 -1
  8. package/exif-reader.d.ts +213 -38
  9. package/package.json +71 -11
  10. package/src/base64-image.js +27 -0
  11. package/src/composable/brand.js +10 -0
  12. package/src/composable/composition-tag-filter.js +97 -0
  13. package/src/composable/composition.js +195 -0
  14. package/src/composable/core.d.ts +148 -0
  15. package/src/composable/core.js +526 -0
  16. package/src/composable/exif-block-reader.js +197 -0
  17. package/src/composable/formats/avif.js +19 -0
  18. package/src/composable/formats/gif.js +28 -0
  19. package/src/composable/formats/heic.js +19 -0
  20. package/src/composable/formats/iso-bmff-file-reader.js +14 -0
  21. package/src/composable/formats/jpeg.js +55 -0
  22. package/src/composable/formats/jxl.js +30 -0
  23. package/src/composable/formats/png.js +187 -0
  24. package/src/composable/formats/tiff.js +18 -0
  25. package/src/composable/formats/webp.js +28 -0
  26. package/src/composable/formats/xml.js +18 -0
  27. package/src/composable/formats.d.ts +17 -0
  28. package/src/composable/formats.js +17 -0
  29. package/src/composable/group-helpers.js +129 -0
  30. package/src/composable/groups/canon.js +26 -0
  31. package/src/composable/groups/composite.js +43 -0
  32. package/src/composable/groups/exif.js +48 -0
  33. package/src/composable/groups/gps.js +75 -0
  34. package/src/composable/groups/icc.js +52 -0
  35. package/src/composable/groups/iptc.js +86 -0
  36. package/src/composable/groups/maker-notes.js +21 -0
  37. package/src/composable/groups/mpf.js +25 -0
  38. package/src/composable/groups/pentax.js +34 -0
  39. package/src/composable/groups/photoshop.js +18 -0
  40. package/src/composable/groups/thumbnail.js +131 -0
  41. package/src/composable/groups/xmp.js +118 -0
  42. package/src/composable/groups.d.ts +20 -0
  43. package/src/composable/groups.js +105 -0
  44. package/src/composable/iptc-block-reader.js +44 -0
  45. package/src/composable/read-view.js +165 -0
  46. package/src/composable/tag-binding-name.js +17 -0
  47. package/src/composable/tags/exif.d.ts +295 -0
  48. package/src/composable/tags/exif.js +396 -0
  49. package/src/composable/tags/iptc.d.ts +84 -0
  50. package/src/composable/tags/iptc.js +109 -0
  51. package/src/composable/value-budget.js +24 -0
  52. package/src/composite.js +2 -2
  53. package/src/decompression.js +60 -0
  54. package/src/dom-parser.js +5 -6
  55. package/src/engine.js +332 -0
  56. package/src/errors.js +8 -2
  57. package/src/exif-reader.d.ts +8 -0
  58. package/src/exif-reader.js +118 -1121
  59. package/src/file-loaders.js +74 -1
  60. package/src/file-tags.js +9 -9
  61. package/src/image-header-avif.js +7 -8
  62. package/src/image-header-gif.js +9 -10
  63. package/src/image-header-heic.js +7 -8
  64. package/src/image-header-iso-bmff.js +71 -92
  65. package/src/image-header-jpeg.js +60 -59
  66. package/src/image-header-jxl.js +59 -65
  67. package/src/image-header-png.js +199 -76
  68. package/src/image-header-tiff.js +7 -4
  69. package/src/image-header-webp.js +29 -35
  70. package/src/image-header.js +25 -59
  71. package/src/iptc-tag-names-descriptions.js +334 -0
  72. package/src/iptc-tag-names.js +50 -306
  73. package/src/iptc-tags.js +41 -27
  74. package/src/jfif-tags.js +9 -9
  75. package/src/load-auto.js +2 -2
  76. package/src/loadview-pipeline.js +197 -498
  77. package/src/mpf-tags.js +10 -7
  78. package/src/node-require.js +15 -2
  79. package/src/png-text-tags.js +90 -327
  80. package/src/tag-filter-config.js +24 -15
  81. package/src/tag-filter.js +67 -3
  82. package/src/tag-names-0th-ifd-descriptions.js +232 -0
  83. package/src/tag-names-0th-ifd.js +49 -173
  84. package/src/tag-names-common.js +263 -211
  85. package/src/tag-names-exif-ifd-descriptions.js +249 -0
  86. package/src/tag-names-exif-ifd.js +55 -187
  87. package/src/tag-names-gps-ifd-descriptions.js +156 -0
  88. package/src/tag-names-gps-ifd.js +39 -146
  89. package/src/tag-names-utils.js +33 -10
  90. package/src/tags-helpers.js +14 -24
  91. package/src/tags.js +23 -11
  92. package/src/thumbnail.js +7 -5
  93. package/src/types.js +2 -0
  94. package/src/unsupported-format-error.js +21 -0
  95. package/src/utils.js +64 -119
  96. package/src/writer/exif-tag-table.js +321 -0
  97. package/src/xml.js +12 -15
  98. package/src/xmp-tag-names.js +42 -21
  99. package/src/xmp-tags.js +9 -10
  100. package/webpack.config.js +1 -1
@@ -0,0 +1,334 @@
1
+ /* This Source Code Form is subject to the terms of the Mozilla Public
2
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
+
5
+ import {getStringValue} from './tag-names-utils.js';
6
+
7
+ export function getModelVersionDescription(value) {
8
+ return ((value[0] << 8) + value[1]).toString();
9
+ }
10
+
11
+ export function getFileFormatDescription(value) {
12
+ return ((value[0] << 8) + value[1]).toString();
13
+ }
14
+
15
+ export function getFileFormatVersionDescription(value) {
16
+ return ((value[0] << 8) + value[1]).toString();
17
+ }
18
+
19
+ export function getARMIdentifierDescription(value) {
20
+ return ((value[0] << 8) + value[1]).toString();
21
+ }
22
+
23
+ export function getARMVersionDescription(value) {
24
+ return ((value[0] << 8) + value[1]).toString();
25
+ }
26
+
27
+ export function getRecordVersionDescription(value) {
28
+ return ((value[0] << 8) + value[1]).toString();
29
+ }
30
+
31
+ export function getEditorialUpdateDescription(value) {
32
+ if (getStringValue(value) === '01') {
33
+ return 'Additional Language';
34
+ }
35
+ return 'Unknown';
36
+ }
37
+
38
+ export function getSubjectReferenceDescription(value) {
39
+ const parts = getStringValue(value).split(':');
40
+ return parts[2] + (parts[3] ? '/' + parts[3] : '') + (parts[4] ? '/' + parts[4] : '');
41
+ }
42
+
43
+ export function getActionAdvisedDescription(value) {
44
+ const string = getStringValue(value);
45
+ if (string === '01') {
46
+ return 'Object Kill';
47
+ } else if (string === '02') {
48
+ return 'Object Replace';
49
+ } else if (string === '03') {
50
+ return 'Object Append';
51
+ } else if (string === '04') {
52
+ return 'Object Reference';
53
+ }
54
+ return 'Unknown';
55
+ }
56
+
57
+ export function getObjectCycleDescription(value) {
58
+ const string = getStringValue(value);
59
+ if (string === 'a') {
60
+ return 'morning';
61
+ } else if (string === 'p') {
62
+ return 'evening';
63
+ } else if (string === 'b') {
64
+ return 'both';
65
+ }
66
+ return 'Unknown';
67
+ }
68
+
69
+ export function getRasterizedCaptionDescription(value) {
70
+ return value;
71
+ }
72
+
73
+ export function getImageOrientationDescription(value) {
74
+ const string = getStringValue(value);
75
+ if (string === 'P') {
76
+ return 'Portrait';
77
+ } else if (string === 'L') {
78
+ return 'Landscape';
79
+ } else if (string === 'S') {
80
+ return 'Square';
81
+ }
82
+ return 'Unknown';
83
+ }
84
+
85
+ export function getAudioTypeDescription(value) {
86
+ const stringValue = getStringValue(value);
87
+ const character0 = stringValue.charAt(0);
88
+ const character1 = stringValue.charAt(1);
89
+ let description = '';
90
+
91
+ if (character0 === '1') {
92
+ description += 'Mono';
93
+ } else if (character0 === '2') {
94
+ description += 'Stereo';
95
+ }
96
+
97
+ if (character1 === 'A') {
98
+ description += ', actuality';
99
+ } else if (character1 === 'C') {
100
+ description += ', question and answer session';
101
+ } else if (character1 === 'M') {
102
+ description += ', music, transmitted by itself';
103
+ } else if (character1 === 'Q') {
104
+ description += ', response to a question';
105
+ } else if (character1 === 'R') {
106
+ description += ', raw sound';
107
+ } else if (character1 === 'S') {
108
+ description += ', scener';
109
+ } else if (character1 === 'V') {
110
+ description += ', voicer';
111
+ } else if (character1 === 'W') {
112
+ description += ', wrap';
113
+ }
114
+
115
+ if (description !== '') {
116
+ return description;
117
+ }
118
+ return stringValue;
119
+ }
120
+
121
+ export function getAudioSamplingRateDescription(value) {
122
+ return parseInt(getStringValue(value), 10) + ' Hz';
123
+ }
124
+
125
+ export function getAudioSamplingResolutionDescription(value) {
126
+ const bits = parseInt(getStringValue(value), 10);
127
+ return bits + (bits === 1 ? ' bit' : ' bits');
128
+ }
129
+
130
+ export function getAudioDurationDescription(value) {
131
+ const duration = getStringValue(value);
132
+ if (duration.length >= 6) {
133
+ return duration.substr(0, 2) + ':' + duration.substr(2, 2) + ':' + duration.substr(4, 2);
134
+ }
135
+ return duration;
136
+ }
137
+
138
+ export function getRecord2DestinationDescription(value) {
139
+ if (value.length === 2) {
140
+ const intValue = getPreviewNumber(value);
141
+ if (intValue === 0) {
142
+ return 'No ObjectData';
143
+ } else if (intValue === 1) {
144
+ return 'IPTC-NAA Digital Newsphoto Parameter Record';
145
+ } else if (intValue === 2) {
146
+ return 'IPTC7901 Recommended Message Format';
147
+ } else if (intValue === 3) {
148
+ return 'Tagged Image File Format (Adobe/Aldus Image data)';
149
+ } else if (intValue === 4) {
150
+ return 'Illustrator (Adobe Graphics data)';
151
+ } else if (intValue === 5) {
152
+ return 'AppleSingle (Apple Computer Inc)';
153
+ } else if (intValue === 6) {
154
+ return 'NAA 89-3 (ANPA 1312)';
155
+ } else if (intValue === 7) {
156
+ return 'MacBinary II';
157
+ } else if (intValue === 8) {
158
+ return 'IPTC Unstructured Character Oriented File Format (UCOFF)';
159
+ } else if (intValue === 9) {
160
+ return 'United Press International ANPA 1312 variant';
161
+ } else if (intValue === 10) {
162
+ return 'United Press International Down-Load Message';
163
+ } else if (intValue === 11) {
164
+ return 'JPEG File Interchange (JFIF)';
165
+ } else if (intValue === 12) {
166
+ return 'Photo-CD Image-Pac (Eastman Kodak)';
167
+ } else if (intValue === 13) {
168
+ return 'Microsoft Bit Mapped Graphics File [*.BMP]';
169
+ } else if (intValue === 14) {
170
+ return 'Digital Audio File [*.WAV] (Microsoft & Creative Labs)';
171
+ } else if (intValue === 15) {
172
+ return 'Audio plus Moving Video [*.AVI] (Microsoft)';
173
+ } else if (intValue === 16) {
174
+ return 'PC DOS/Windows Executable Files [*.COM][*.EXE]';
175
+ } else if (intValue === 17) {
176
+ return 'Compressed Binary File [*.ZIP] (PKWare Inc)';
177
+ } else if (intValue === 18) {
178
+ return 'Audio Interchange File Format AIFF (Apple Computer Inc)';
179
+ } else if (intValue === 19) {
180
+ return 'RIFF Wave (Microsoft Corporation)';
181
+ } else if (intValue === 20) {
182
+ return 'Freehand (Macromedia/Aldus)';
183
+ } else if (intValue === 21) {
184
+ return 'Hypertext Markup Language "HTML" (The Internet Society)';
185
+ } else if (intValue === 22) {
186
+ return 'MPEG 2 Audio Layer 2 (Musicom), ISO/IEC';
187
+ } else if (intValue === 23) {
188
+ return 'MPEG 2 Audio Layer 3, ISO/IEC';
189
+ } else if (intValue === 24) {
190
+ return 'Portable Document File (*.PDF) Adobe';
191
+ } else if (intValue === 25) {
192
+ return 'News Industry Text Format (NITF)';
193
+ } else if (intValue === 26) {
194
+ return 'Tape Archive (*.TAR)';
195
+ } else if (intValue === 27) {
196
+ return 'Tidningarnas Telegrambyrå NITF version (TTNITF DTD)';
197
+ } else if (intValue === 28) {
198
+ return 'Ritzaus Bureau NITF version (RBNITF DTD)';
199
+ } else if (intValue === 29) {
200
+ return 'Corel Draw [*.CDR]';
201
+ }
202
+ return `Unknown format ${intValue}`;
203
+ }
204
+ return getStringValue(value);
205
+ }
206
+
207
+ export function getObjectDataPreviewFileFormatVersionDescription(value, tags) {
208
+ // Format ID, Version ID, Version Description
209
+ const formatVersions = {
210
+ 0: {0: '1'},
211
+ 1: {1: '1', 2: '2', 3: '3', 4: '4'},
212
+ 2: {4: '4'},
213
+ 3: {1: '5.0', 2: '6.0'},
214
+ 4: {1: '1.40'},
215
+ 5: {1: '2'},
216
+ 6: {1: '1'},
217
+ 11: {1: '1.02'},
218
+ 20: {1: '3.1', 2: '4.0', 3: '5.0', 4: '5.5'},
219
+ 21: {2: '2.0'}
220
+ };
221
+ const version = getPreviewNumber(value);
222
+
223
+ if (tags['ObjectData Preview File Format']) {
224
+ const format = getPreviewNumber(tags['ObjectData Preview File Format'].value);
225
+ if (Object.prototype.hasOwnProperty.call(formatVersions, format)
226
+ && Object.prototype.hasOwnProperty.call(formatVersions[format], version)) {
227
+ return formatVersions[format][version];
228
+ }
229
+ }
230
+
231
+ const versionNumber = getBinaryNumber(value);
232
+ return versionNumber === null ? getStringValue(value) : String(versionNumber);
233
+ }
234
+
235
+ export function getSizeModeDescription(value) {
236
+ return (value[0]).toString();
237
+ }
238
+
239
+ export function getMaxSubfileSizeDescription(value) {
240
+ let n = 0;
241
+ for (let i = 0; i < value.length; i++) {
242
+ n = (n << 8) + value[i];
243
+ }
244
+ return n.toString();
245
+ }
246
+
247
+ export function getObjectDataSizeAnnouncedDescription(value) {
248
+ let n = 0;
249
+ for (let i = 0; i < value.length; i++) {
250
+ n = (n << 8) + value[i];
251
+ }
252
+ return n.toString();
253
+ }
254
+
255
+ export function getMaximumObjectDataSizeDescription(value) {
256
+ let n = 0;
257
+ for (let i = 0; i < value.length; i++) {
258
+ n = (n << 8) + value[i];
259
+ }
260
+ return n.toString();
261
+ }
262
+
263
+ export function getCreationDate(value) {
264
+ const date = getStringValue(value);
265
+
266
+ if (date.length >= 8) {
267
+ return date.substr(0, 4) + '-' + date.substr(4, 2) + '-' + date.substr(6, 2);
268
+ }
269
+
270
+ return date;
271
+ }
272
+
273
+ export function getCreationTime(value) {
274
+ const time = getStringValue(value);
275
+ let parsedTime = time;
276
+
277
+ if (time.length >= 6) {
278
+ parsedTime = time.substr(0, 2) + ':' + time.substr(2, 2) + ':' + time.substr(4, 2);
279
+ if (time.length === 11) {
280
+ parsedTime += time.substr(6, 1) + time.substr(7, 2) + ':' + time.substr(9, 2);
281
+ }
282
+ }
283
+
284
+ return parsedTime;
285
+ }
286
+
287
+ export function getEncodingName(value) {
288
+ const string = getStringValue(value);
289
+ if (string === '\x1b%G') {
290
+ return 'UTF-8';
291
+ } else if (string === '\x1b%5') {
292
+ return 'Windows-1252';
293
+ } else if (string === '\x1b%/G') {
294
+ return 'UTF-8 Level 1';
295
+ } else if (string === '\x1b%/H') {
296
+ return 'UTF-8 Level 2';
297
+ } else if (string === '\x1b%/I') {
298
+ return 'UTF-8 Level 3';
299
+ } else if (string === '\x1B/A') {
300
+ return 'ISO-8859-1';
301
+ } else if (string === '\x1B/B') {
302
+ return 'ISO-8859-2';
303
+ } else if (string === '\x1B/C') {
304
+ return 'ISO-8859-3';
305
+ } else if (string === '\x1B/D') {
306
+ return 'ISO-8859-4';
307
+ } else if (string === '\x1B/@') {
308
+ return 'ISO-8859-5';
309
+ } else if (string === '\x1B/G') {
310
+ return 'ISO-8859-6';
311
+ } else if (string === '\x1B/F') {
312
+ return 'ISO-8859-7';
313
+ } else if (string === '\x1B/H') {
314
+ return 'ISO-8859-8';
315
+ }
316
+ return 'Unknown';
317
+ }
318
+
319
+ // IIM stores 2:200 and 2:201 as 2-octet binary; two ASCII digits are the text form.
320
+ function getPreviewNumber(value) {
321
+ const number = getBinaryNumber(value);
322
+ return number === null ? parseInt(getStringValue(value), 10) : number;
323
+ }
324
+
325
+ function getBinaryNumber(value) {
326
+ if (value.length !== 2 || (isAsciiDigit(value[0]) && isAsciiDigit(value[1]))) {
327
+ return null;
328
+ }
329
+ return (value[0] << 8) + value[1];
330
+ }
331
+
332
+ function isAsciiDigit(octet) {
333
+ return octet >= 0x30 && octet <= 0x39;
334
+ }