exifreader 4.48.1 → 4.49.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.
- package/README.md +38 -32
- package/dist/exif-reader.js +1 -1
- package/dist/exif-reader.js.map +1 -1
- package/package.json +1 -1
- package/src/exif-reader.js +241 -166
- package/src/image-header-iso-bmff.js +261 -39
- package/src/image-header-jxl.js +6 -6
- package/src/iptc-tag-names.js +35 -17
- package/src/iso-bmff-file-tags.js +86 -0
- package/src/loadview-pipeline.js +106 -28
- package/src/png-text-tags.js +88 -49
- package/src/tag-decoder.js +3 -3
- package/src/tag-names-0th-ifd.js +51 -42
- package/src/tag-names-common.js +19 -15
- package/src/tag-names-exif-ifd.js +7 -7
- package/src/tag-names-utils.js +24 -3
- package/src/tags-helpers.js +20 -0
- package/src/utils.js +66 -4
- package/src/xmp-tag-names.js +1 -1
package/src/loadview-pipeline.js
CHANGED
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
import Constants from './constants.js';
|
|
6
6
|
|
|
7
|
+
// The order the main Exif block reads them in. It is the key order of expanded
|
|
8
|
+
// output, and in flat output later groups win a key clash, so Exif wins over
|
|
9
|
+
// all of them but an ApplicationNotes XMP packet.
|
|
10
|
+
export const EXIF_CARRIED_GROUP_ORDER = ['iptc', 'xmp', 'photoshop', 'icc', 'makerNotes'];
|
|
11
|
+
|
|
7
12
|
export function buildTagsFromMergeSteps({
|
|
8
13
|
mergeSteps,
|
|
9
14
|
deferredResults,
|
|
@@ -117,22 +122,25 @@ export function applyMergeStep({
|
|
|
117
122
|
}
|
|
118
123
|
|
|
119
124
|
if (Constants.USE_JXL && step.type === 'mergeBrobExifDeferred') {
|
|
120
|
-
const
|
|
121
|
-
if (!
|
|
125
|
+
const resolved = deferredResults[step.deferredKey];
|
|
126
|
+
if (!resolved) {
|
|
122
127
|
return tags;
|
|
123
128
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
parsedGroups.exif = !parsedGroups.exif ? parsedExifTags : deps.objectAssign({}, parsedGroups.exif, parsedExifTags);
|
|
127
|
-
|
|
128
|
-
if (!tagFilter.shouldReturnGroup('exif')) {
|
|
129
|
+
addEmbeddedExifThumbnail(embeddedExifThumbnails, resolved.thumbnail);
|
|
130
|
+
if (Object.keys(resolved.exifTags).length === 0) {
|
|
129
131
|
return tags;
|
|
130
132
|
}
|
|
131
133
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
return addExifAndCarriedGroupsToTagsAndGroups({
|
|
135
|
+
exifTags: resolved.exifTags,
|
|
136
|
+
carriedGroups: resolved.carriedGroups,
|
|
137
|
+
parsedGroups,
|
|
138
|
+
expanded,
|
|
139
|
+
tagFilter,
|
|
140
|
+
tags,
|
|
141
|
+
deps,
|
|
142
|
+
merge: createCopyingMerge(deps),
|
|
143
|
+
});
|
|
136
144
|
}
|
|
137
145
|
|
|
138
146
|
if (Constants.USE_JXL && step.type === 'mergeBrobXmpDeferred') {
|
|
@@ -202,6 +210,7 @@ export function applyMergeStep({
|
|
|
202
210
|
return addPngTextReadTagsToTagsAndGroups({
|
|
203
211
|
readTags: step.readTags,
|
|
204
212
|
embeddedExifTags: step.embeddedExifTags,
|
|
213
|
+
exifCarriedGroups: step.exifCarriedGroups,
|
|
205
214
|
embeddedIptcTags: step.embeddedIptcTags,
|
|
206
215
|
parsedGroups,
|
|
207
216
|
expanded,
|
|
@@ -221,6 +230,7 @@ export function applyMergeStep({
|
|
|
221
230
|
tags = addPngTextReadTagsToTagsAndGroups({
|
|
222
231
|
readTags: entry.readTags || {},
|
|
223
232
|
embeddedExifTags: entry.embeddedExifTags,
|
|
233
|
+
exifCarriedGroups: entry.exifCarriedGroups,
|
|
224
234
|
embeddedIptcTags: entry.embeddedIptcTags,
|
|
225
235
|
parsedGroups,
|
|
226
236
|
expanded,
|
|
@@ -378,7 +388,7 @@ function hasImage(thumbnail) {
|
|
|
378
388
|
}
|
|
379
389
|
|
|
380
390
|
function getFirstEmbeddedExifThumbnailWithImage(embeddedExifThumbnails) {
|
|
381
|
-
if (!(Constants.USE_PNG && Constants.USE_EXIF && Constants.USE_THUMBNAIL)) {
|
|
391
|
+
if (!((Constants.USE_PNG || Constants.USE_JXL) && Constants.USE_EXIF && Constants.USE_THUMBNAIL)) {
|
|
382
392
|
return undefined;
|
|
383
393
|
}
|
|
384
394
|
return embeddedExifThumbnails.filter(hasImage)[0];
|
|
@@ -424,6 +434,7 @@ export function mergeMergeGroup(tags, groupKey, returnedTags, expanded, deps) {
|
|
|
424
434
|
export function addPngTextReadTagsToTagsAndGroups({
|
|
425
435
|
readTags,
|
|
426
436
|
embeddedExifTags,
|
|
437
|
+
exifCarriedGroups,
|
|
427
438
|
embeddedIptcTags,
|
|
428
439
|
parsedGroups,
|
|
429
440
|
expanded,
|
|
@@ -433,22 +444,16 @@ export function addPngTextReadTagsToTagsAndGroups({
|
|
|
433
444
|
merge = createCopyingMerge(deps),
|
|
434
445
|
}) {
|
|
435
446
|
if (embeddedExifTags) {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
if (expanded) {
|
|
447
|
-
merge.group(tags, 'exif', returnedEmbeddedExifTags);
|
|
448
|
-
} else {
|
|
449
|
-
tags = merge.topLevel(tags, returnedEmbeddedExifTags);
|
|
450
|
-
}
|
|
451
|
-
}
|
|
447
|
+
tags = addExifAndCarriedGroupsToTagsAndGroups({
|
|
448
|
+
exifTags: embeddedExifTags,
|
|
449
|
+
carriedGroups: exifCarriedGroups || {},
|
|
450
|
+
parsedGroups,
|
|
451
|
+
expanded,
|
|
452
|
+
tagFilter,
|
|
453
|
+
tags,
|
|
454
|
+
deps,
|
|
455
|
+
merge,
|
|
456
|
+
});
|
|
452
457
|
}
|
|
453
458
|
|
|
454
459
|
if (embeddedIptcTags) {
|
|
@@ -493,6 +498,79 @@ export function addPngTextReadTagsToTagsAndGroups({
|
|
|
493
498
|
return tags;
|
|
494
499
|
}
|
|
495
500
|
|
|
501
|
+
/**
|
|
502
|
+
* Merges one Exif block and the groups it carries in the order the main Exif
|
|
503
|
+
* block merges them: the carried groups, then Exif, then in flat output the
|
|
504
|
+
* ApplicationNotes XMP. The carried groups arrive parsed and are not filtered
|
|
505
|
+
* for parse again.
|
|
506
|
+
*
|
|
507
|
+
* @returns {object} The tags, which flat output replaces rather than mutates.
|
|
508
|
+
*/
|
|
509
|
+
export function addExifAndCarriedGroupsToTagsAndGroups({
|
|
510
|
+
exifTags,
|
|
511
|
+
carriedGroups,
|
|
512
|
+
parsedGroups,
|
|
513
|
+
expanded,
|
|
514
|
+
tagFilter,
|
|
515
|
+
tags,
|
|
516
|
+
deps,
|
|
517
|
+
merge,
|
|
518
|
+
}) {
|
|
519
|
+
let flatXmpGroup = undefined;
|
|
520
|
+
|
|
521
|
+
for (let i = 0; i < EXIF_CARRIED_GROUP_ORDER.length; i++) {
|
|
522
|
+
const groupKey = EXIF_CARRIED_GROUP_ORDER[i];
|
|
523
|
+
const group = carriedGroups[groupKey];
|
|
524
|
+
if (group === undefined) {
|
|
525
|
+
continue;
|
|
526
|
+
}
|
|
527
|
+
if (groupKey === 'xmp' && !expanded) {
|
|
528
|
+
flatXmpGroup = group;
|
|
529
|
+
continue;
|
|
530
|
+
}
|
|
531
|
+
tags = addCarriedGroup(groupKey, group);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
if (exifTags) {
|
|
535
|
+
const parsedExifTags = deps.filterTagsForParse('exif', exifTags, tagFilter);
|
|
536
|
+
merge.group(parsedGroups, 'exif', parsedExifTags);
|
|
537
|
+
|
|
538
|
+
if (tagFilter.shouldReturnGroup('exif')) {
|
|
539
|
+
const returnedExifTags = deps.filterTagsForReturn('exif', parsedExifTags, tagFilter);
|
|
540
|
+
if (expanded) {
|
|
541
|
+
merge.group(tags, 'exif', returnedExifTags);
|
|
542
|
+
} else {
|
|
543
|
+
tags = merge.topLevel(tags, returnedExifTags);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
if (flatXmpGroup !== undefined) {
|
|
549
|
+
tags = addCarriedGroup('xmp', flatXmpGroup, true);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
return tags;
|
|
553
|
+
|
|
554
|
+
function addCarriedGroup(groupKey, group, isFlatXmp) {
|
|
555
|
+
merge.group(parsedGroups, groupKey, group);
|
|
556
|
+
if (!tagFilter.shouldReturnGroup(groupKey)) {
|
|
557
|
+
return tags;
|
|
558
|
+
}
|
|
559
|
+
const returnedTags = deps.filterTagsForReturn(groupKey, group, tagFilter);
|
|
560
|
+
if (expanded) {
|
|
561
|
+
merge.group(tags, groupKey, returnedTags);
|
|
562
|
+
return tags;
|
|
563
|
+
}
|
|
564
|
+
return merge.topLevel(tags, isFlatXmp ? getXmpTagsWithoutRaw(returnedTags) : returnedTags);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
function getXmpTagsWithoutRaw(xmpTags) {
|
|
568
|
+
const xmpTagsWithoutRaw = deps.objectAssign({}, xmpTags);
|
|
569
|
+
delete xmpTagsWithoutRaw._raw;
|
|
570
|
+
return xmpTagsWithoutRaw;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
|
|
496
574
|
function createCopyingMerge(deps) {
|
|
497
575
|
return {
|
|
498
576
|
group(holder, key, source) {
|
package/src/png-text-tags.js
CHANGED
|
@@ -11,7 +11,7 @@ import Tags from './tags.js';
|
|
|
11
11
|
import IptcTags from './iptc-tags.js';
|
|
12
12
|
import Constants from './constants.js';
|
|
13
13
|
import {NOOP_TAG_FILTER} from './tag-filter.js';
|
|
14
|
-
import {addDecompressedValueAllowance, addDecompressedIptcAllowance} from './tags-helpers.js';
|
|
14
|
+
import {addDecompressedValueAllowance, addDecompressedIptcAllowance, takeEmbeddedExifThumbnail} from './tags-helpers.js';
|
|
15
15
|
|
|
16
16
|
export default {
|
|
17
17
|
read
|
|
@@ -29,6 +29,7 @@ const MAX_COMPRESSED_TEXT_CHUNKS = 255;
|
|
|
29
29
|
const MAX_DECOMPRESSIONS_IN_FLIGHT = 4;
|
|
30
30
|
// PNG spec: a keyword is 1-79 bytes.
|
|
31
31
|
const MAX_KEYWORD_LENGTH = 79;
|
|
32
|
+
const IPTC_PROFILE_NAME = 'raw profile type iptc';
|
|
32
33
|
// Our own bound: BCP 47 sets no maximum, but real tags are far shorter.
|
|
33
34
|
const MAX_LANGUAGE_TAG_LENGTH = 79;
|
|
34
35
|
|
|
@@ -38,14 +39,21 @@ const MAX_LANGUAGE_TAG_LENGTH = 79;
|
|
|
38
39
|
* decoded Exif raw profile, its thumbnail IFD tags and the TIFF header offset;
|
|
39
40
|
* returns the thumbnail tags, with `image` set when the thumbnail was read.
|
|
40
41
|
* No thumbnail is returned when it is not passed.
|
|
41
|
-
* @
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
42
|
+
* @param {function(DataView, object, number, number, object, {decompressed: boolean, hasIptcBlock: boolean}): object} [readCarriedGroups]
|
|
43
|
+
* Called with a decoded Exif raw profile, the Exif tags read from it, the TIFF
|
|
44
|
+
* header offset, the byte order, the value budget and where the profile came
|
|
45
|
+
* from: `decompressed` when the chunk was compressed, `hasIptcBlock` when the
|
|
46
|
+
* file has a `Raw profile type iptc` chunk. Returns the parsed groups the Exif
|
|
47
|
+
* carries, keyed by group name. No groups are read when it is not passed.
|
|
48
|
+
* @returns {{readTags: object, embeddedExifTags: object|undefined, embeddedIptcTags: object|undefined, embeddedExifThumbnail: object|undefined, exifCarriedGroups: object|undefined, readTagsPromise: Promise<object[]>|undefined}}
|
|
49
|
+
* `readTags`, the two embedded groups, `exifCarriedGroups` and
|
|
50
|
+
* `embeddedExifThumbnail` come from uncompressed chunks and are ready at
|
|
51
|
+
* once; the embedded groups and `exifCarriedGroups` are undefined when no
|
|
52
|
+
* uncompressed raw profile was parsed, and `embeddedExifThumbnail` is the
|
|
53
|
+
* first thumbnail with an image. `readTagsPromise` resolves to one result per
|
|
54
|
+
* compressed chunk, in chunk order, each with its own `exifCarriedGroups`, and
|
|
55
|
+
* its own `embeddedExifThumbnail` when it has one and no uncompressed chunk
|
|
56
|
+
* had one, and is undefined when none is read.
|
|
49
57
|
*/
|
|
50
58
|
function read(
|
|
51
59
|
dataView,
|
|
@@ -56,12 +64,15 @@ function read(
|
|
|
56
64
|
tagFilter = NOOP_TAG_FILTER,
|
|
57
65
|
decompressConfig,
|
|
58
66
|
valueBudget,
|
|
59
|
-
getThumbnail
|
|
67
|
+
getThumbnail,
|
|
68
|
+
readCarriedGroups
|
|
60
69
|
) {
|
|
61
70
|
const tags = {};
|
|
62
71
|
let embeddedExifTags;
|
|
63
72
|
let embeddedIptcTags;
|
|
64
73
|
let embeddedExifThumbnail;
|
|
74
|
+
let exifCarriedGroups;
|
|
75
|
+
const uncompressedRawProfiles = [];
|
|
65
76
|
const compressedChunks = [];
|
|
66
77
|
|
|
67
78
|
for (let i = 0; i < pngTextChunks.length; i++) {
|
|
@@ -75,23 +86,7 @@ function read(
|
|
|
75
86
|
if (textChunk.compressionMethod === COMPRESSION_METHOD_NONE) {
|
|
76
87
|
const tag = getUncompressedTag(textChunk);
|
|
77
88
|
if (isRawProfileTag(tag)) {
|
|
78
|
-
|
|
79
|
-
tag,
|
|
80
|
-
includeUnknown,
|
|
81
|
-
computed,
|
|
82
|
-
tagFilter,
|
|
83
|
-
valueBudget,
|
|
84
|
-
embeddedExifThumbnail ? undefined : getThumbnail
|
|
85
|
-
);
|
|
86
|
-
if (rawProfileTags.embeddedExifTags) {
|
|
87
|
-
embeddedExifTags = objectAssign(embeddedExifTags || {}, rawProfileTags.embeddedExifTags);
|
|
88
|
-
}
|
|
89
|
-
if (rawProfileTags.embeddedExifThumbnail) {
|
|
90
|
-
embeddedExifThumbnail = rawProfileTags.embeddedExifThumbnail;
|
|
91
|
-
}
|
|
92
|
-
if (rawProfileTags.embeddedIptcTags) {
|
|
93
|
-
embeddedIptcTags = objectAssign(embeddedIptcTags || {}, rawProfileTags.embeddedIptcTags);
|
|
94
|
-
}
|
|
89
|
+
uncompressedRawProfiles.push(tag);
|
|
95
90
|
} else if (tag.name && tagFilter.shouldParseGroup('png')) {
|
|
96
91
|
setProperty(tags, getTagKey(tag.name), {
|
|
97
92
|
value: tag.value,
|
|
@@ -103,6 +98,35 @@ function read(
|
|
|
103
98
|
}
|
|
104
99
|
}
|
|
105
100
|
|
|
101
|
+
const hasIptcProfile = uncompressedRawProfiles.some((tag) => isIptcGroupTag(tag.name, tag.value))
|
|
102
|
+
|| compressedChunks.some(isCompressedIptcProfile);
|
|
103
|
+
|
|
104
|
+
for (let i = 0; i < uncompressedRawProfiles.length; i++) {
|
|
105
|
+
const rawProfileTags = getTagsFromTextTag(
|
|
106
|
+
uncompressedRawProfiles[i],
|
|
107
|
+
includeUnknown,
|
|
108
|
+
computed,
|
|
109
|
+
tagFilter,
|
|
110
|
+
valueBudget,
|
|
111
|
+
embeddedExifThumbnail ? undefined : getThumbnail,
|
|
112
|
+
readCarriedGroups,
|
|
113
|
+
false,
|
|
114
|
+
hasIptcProfile
|
|
115
|
+
);
|
|
116
|
+
if (rawProfileTags.embeddedExifTags) {
|
|
117
|
+
embeddedExifTags = objectAssign(embeddedExifTags || {}, rawProfileTags.embeddedExifTags);
|
|
118
|
+
}
|
|
119
|
+
if (rawProfileTags.exifCarriedGroups) {
|
|
120
|
+
exifCarriedGroups = mergeCarriedGroups(exifCarriedGroups || {}, rawProfileTags.exifCarriedGroups);
|
|
121
|
+
}
|
|
122
|
+
if (rawProfileTags.embeddedExifThumbnail) {
|
|
123
|
+
embeddedExifThumbnail = rawProfileTags.embeddedExifThumbnail;
|
|
124
|
+
}
|
|
125
|
+
if (rawProfileTags.embeddedIptcTags) {
|
|
126
|
+
embeddedIptcTags = objectAssign(embeddedIptcTags || {}, rawProfileTags.embeddedIptcTags);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
106
130
|
const compressedThumbnailReader = embeddedExifThumbnail ? undefined : getThumbnail;
|
|
107
131
|
const decompressionTasks = compressedChunks.map((textChunk) => () => decompressTextChunk(textChunk, decompressConfig)
|
|
108
132
|
.then((tag) => getTagsFromTextTag(
|
|
@@ -112,7 +136,9 @@ function read(
|
|
|
112
136
|
tagFilter,
|
|
113
137
|
valueBudget,
|
|
114
138
|
compressedThumbnailReader,
|
|
115
|
-
|
|
139
|
+
readCarriedGroups,
|
|
140
|
+
true,
|
|
141
|
+
hasIptcProfile
|
|
116
142
|
)));
|
|
117
143
|
|
|
118
144
|
return {
|
|
@@ -120,10 +146,24 @@ function read(
|
|
|
120
146
|
embeddedExifTags,
|
|
121
147
|
embeddedIptcTags,
|
|
122
148
|
embeddedExifThumbnail,
|
|
149
|
+
exifCarriedGroups,
|
|
123
150
|
readTagsPromise: decompressionTasks.length > 0 ? runTasksInOrder(decompressionTasks, MAX_DECOMPRESSIONS_IN_FLIGHT) : undefined
|
|
124
151
|
};
|
|
125
152
|
}
|
|
126
153
|
|
|
154
|
+
// A compressed profile counts before its value can be checked.
|
|
155
|
+
function isCompressedIptcProfile({type, langChars, keywordChars}) {
|
|
156
|
+
return getName(type, langChars, keywordChars).toLowerCase() === IPTC_PROFILE_NAME;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function mergeCarriedGroups(target, source) {
|
|
160
|
+
const groupKeys = Object.keys(source);
|
|
161
|
+
for (let i = 0; i < groupKeys.length; i++) {
|
|
162
|
+
target[groupKeys[i]] = objectAssign(target[groupKeys[i]] || {}, source[groupKeys[i]]);
|
|
163
|
+
}
|
|
164
|
+
return target;
|
|
165
|
+
}
|
|
166
|
+
|
|
127
167
|
function parseTextChunk(dataView, offset, length, type) {
|
|
128
168
|
const keywordChars = [];
|
|
129
169
|
const langChars = [];
|
|
@@ -176,7 +216,7 @@ function isRawProfileTag({name, value}) {
|
|
|
176
216
|
return isExifGroupTag(name, value) || isIptcGroupTag(name, value);
|
|
177
217
|
}
|
|
178
218
|
|
|
179
|
-
function getTagsFromTextTag({name, value, description}, includeUnknown, computed, tagFilter, valueBudget, getThumbnail, isDecompressed) {
|
|
219
|
+
function getTagsFromTextTag({name, value, description}, includeUnknown, computed, tagFilter, valueBudget, getThumbnail, readCarriedGroups, isDecompressed, hasIptcProfile) {
|
|
180
220
|
try {
|
|
181
221
|
if (Constants.USE_EXIF && isExifGroupTag(name, value)) {
|
|
182
222
|
if (!tagFilter.shouldParseGroup('exif')) {
|
|
@@ -186,18 +226,33 @@ function getTagsFromTextTag({name, value, description}, includeUnknown, computed
|
|
|
186
226
|
if (isDecompressed) {
|
|
187
227
|
addDecompressedValueAllowance(valueBudget, exifDataView.byteLength);
|
|
188
228
|
}
|
|
189
|
-
const embeddedExifTags = Tags.read(
|
|
229
|
+
const {tags: embeddedExifTags, byteOrder} = Tags.read(
|
|
190
230
|
exifDataView,
|
|
191
231
|
EXIF_OFFSET,
|
|
192
232
|
includeUnknown,
|
|
193
233
|
computed,
|
|
194
234
|
tagFilter,
|
|
195
235
|
valueBudget
|
|
196
|
-
)
|
|
236
|
+
);
|
|
237
|
+
const result = {embeddedExifTags};
|
|
238
|
+
if (readCarriedGroups) {
|
|
239
|
+
result.exifCarriedGroups = readCarriedGroups(
|
|
240
|
+
exifDataView,
|
|
241
|
+
embeddedExifTags,
|
|
242
|
+
EXIF_OFFSET,
|
|
243
|
+
byteOrder,
|
|
244
|
+
valueBudget,
|
|
245
|
+
{decompressed: isDecompressed, hasIptcBlock: hasIptcProfile}
|
|
246
|
+
);
|
|
247
|
+
}
|
|
197
248
|
if (embeddedExifTags['MakerNote']) {
|
|
198
249
|
delete embeddedExifTags['MakerNote'].__offset;
|
|
199
250
|
}
|
|
200
|
-
|
|
251
|
+
const thumbnail = takeEmbeddedExifThumbnail(embeddedExifTags, exifDataView, EXIF_OFFSET, getThumbnail);
|
|
252
|
+
if (thumbnail) {
|
|
253
|
+
result.embeddedExifThumbnail = thumbnail;
|
|
254
|
+
}
|
|
255
|
+
return result;
|
|
201
256
|
} else if (Constants.USE_IPTC && isIptcGroupTag(name, value)) {
|
|
202
257
|
if (!tagFilter.shouldParseGroup('iptc')) {
|
|
203
258
|
return {};
|
|
@@ -232,22 +287,6 @@ function getTagsFromTextTag({name, value, description}, includeUnknown, computed
|
|
|
232
287
|
return {};
|
|
233
288
|
}
|
|
234
289
|
|
|
235
|
-
function withEmbeddedExifThumbnail(result, exifDataView, getThumbnail) {
|
|
236
|
-
const thumbnailIfdTags = result.embeddedExifTags.Thumbnail;
|
|
237
|
-
if (!thumbnailIfdTags) {
|
|
238
|
-
return result;
|
|
239
|
-
}
|
|
240
|
-
delete result.embeddedExifTags.Thumbnail;
|
|
241
|
-
|
|
242
|
-
if (getThumbnail) {
|
|
243
|
-
const thumbnail = getThumbnail(exifDataView, thumbnailIfdTags, EXIF_OFFSET);
|
|
244
|
-
if (thumbnail.image) {
|
|
245
|
-
result.embeddedExifThumbnail = thumbnail;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
return result;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
290
|
function decompressTextChunk({type, keywordChars, langChars, compressionMethod, valueChars}, decompressConfig) {
|
|
252
291
|
if (valueChars === undefined) {
|
|
253
292
|
return Promise.resolve(constructPlaceholderTag(type, langChars, keywordChars));
|
|
@@ -354,7 +393,7 @@ function isExifGroupTag(name, value) {
|
|
|
354
393
|
}
|
|
355
394
|
|
|
356
395
|
function isIptcGroupTag(name, value) {
|
|
357
|
-
return name.toLowerCase() ===
|
|
396
|
+
return name.toLowerCase() === IPTC_PROFILE_NAME && value.substring(1, 5) === 'iptc';
|
|
358
397
|
}
|
|
359
398
|
|
|
360
399
|
function decodeRawData(value) {
|
package/src/tag-decoder.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
4
|
|
|
5
5
|
import TextDecoder from './text-decoder.js';
|
|
6
|
-
import {decodeUtf8ByteString, tryDecodeUtf8ByteString} from './utils.js';
|
|
6
|
+
import {decodeUtf8ByteString, getByteString, tryDecodeUtf8ByteString} from './utils.js';
|
|
7
7
|
|
|
8
8
|
const TAG_HEADER_SIZE = 5;
|
|
9
9
|
|
|
@@ -42,7 +42,7 @@ function decode(encoding, tagValue) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
const stringValue = tagValue
|
|
45
|
+
const stringValue = getByteString(tagValue);
|
|
46
46
|
const decoded = tryDecodeUtf8ByteString(stringValue);
|
|
47
47
|
if (decoded !== undefined) {
|
|
48
48
|
return decoded;
|
|
@@ -65,5 +65,5 @@ function decodeWindows1252(tagValue) {
|
|
|
65
65
|
const mapped = WINDOWS_1252_C1_MAP[byte];
|
|
66
66
|
codePoints[i] = mapped !== undefined ? mapped : byte;
|
|
67
67
|
}
|
|
68
|
-
return
|
|
68
|
+
return getByteString(codePoints);
|
|
69
69
|
}
|
package/src/tag-names-0th-ifd.js
CHANGED
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
4
|
|
|
5
5
|
import TagNamesCommon from './tag-names-common.js';
|
|
6
|
+
import {joinMapped} from './utils.js';
|
|
7
|
+
import {getTableDescription} from './tag-names-utils.js';
|
|
6
8
|
|
|
7
9
|
export default {
|
|
8
10
|
0x000b: 'ProcessingSoftware',
|
|
9
11
|
0x00fe: {
|
|
10
12
|
name: 'SubfileType',
|
|
11
|
-
description: (value) => ({
|
|
13
|
+
description: (value) => getTableDescription({
|
|
12
14
|
0x0: 'Full-resolution image',
|
|
13
15
|
0x1: 'Reduced-resolution image',
|
|
14
16
|
0x2: 'Single page of multi-page image',
|
|
@@ -19,15 +21,15 @@ export default {
|
|
|
19
21
|
0x7: 'Transparency mask of reduced-resolution multi-page image',
|
|
20
22
|
0x10001: 'Alternate reduced-resolution image',
|
|
21
23
|
0xffffffff: 'Invalid'
|
|
22
|
-
})
|
|
24
|
+
}, value)
|
|
23
25
|
},
|
|
24
26
|
0x00ff: {
|
|
25
27
|
name: 'OldSubfileType',
|
|
26
|
-
description: (value) => ({
|
|
28
|
+
description: (value) => getTableDescription({
|
|
27
29
|
0: 'Full-resolution image',
|
|
28
30
|
1: 'Reduced-resolution image',
|
|
29
31
|
2: 'Single page of multi-page image'
|
|
30
|
-
})
|
|
32
|
+
}, value)
|
|
31
33
|
},
|
|
32
34
|
0x0100: 'ImageWidth',
|
|
33
35
|
0x0101: 'ImageLength',
|
|
@@ -36,20 +38,20 @@ export default {
|
|
|
36
38
|
0x0106: 'PhotometricInterpretation',
|
|
37
39
|
0x0107: {
|
|
38
40
|
name: 'Thresholding',
|
|
39
|
-
description: (value) => ({
|
|
41
|
+
description: (value) => getTableDescription({
|
|
40
42
|
1: 'No dithering or halftoning',
|
|
41
43
|
2: 'Ordered dither or halfton',
|
|
42
44
|
3: 'Randomized dither'
|
|
43
|
-
})
|
|
45
|
+
}, value)
|
|
44
46
|
},
|
|
45
47
|
0x0108: 'CellWidth',
|
|
46
48
|
0x0109: 'CellLength',
|
|
47
49
|
0x010a: {
|
|
48
50
|
name: 'FillOrder',
|
|
49
|
-
description: (value) => ({
|
|
51
|
+
description: (value) => getTableDescription({
|
|
50
52
|
1: 'Normal',
|
|
51
53
|
2: 'Reversed'
|
|
52
|
-
})
|
|
54
|
+
}, value)
|
|
53
55
|
},
|
|
54
56
|
0x010d: 'DocumentName',
|
|
55
57
|
0x010e: 'ImageDescription',
|
|
@@ -115,13 +117,13 @@ export default {
|
|
|
115
117
|
},
|
|
116
118
|
0x0122: {
|
|
117
119
|
name: 'GrayResponseUnit',
|
|
118
|
-
description: (value) => ({
|
|
120
|
+
description: (value) => getTableDescription({
|
|
119
121
|
1: '0.1',
|
|
120
122
|
2: '0.001',
|
|
121
123
|
3: '0.0001',
|
|
122
124
|
4: '1e-05',
|
|
123
125
|
5: '1e-06'
|
|
124
|
-
})
|
|
126
|
+
}, value)
|
|
125
127
|
},
|
|
126
128
|
0x0128: {
|
|
127
129
|
name: 'ResolutionUnit',
|
|
@@ -136,15 +138,11 @@ export default {
|
|
|
136
138
|
0x013d: 'Predictor',
|
|
137
139
|
0x013e: {
|
|
138
140
|
'name': 'WhitePoint',
|
|
139
|
-
'description': (values) =>
|
|
140
|
-
return values.map((value) => `${value[0]}/${value[1]}`).join(', ');
|
|
141
|
-
}
|
|
141
|
+
'description': (values) => joinMapped(values, getRationalText, ', ')
|
|
142
142
|
},
|
|
143
143
|
0x013f: {
|
|
144
144
|
'name': 'PrimaryChromaticities',
|
|
145
|
-
'description': (values) =>
|
|
146
|
-
return values.map((value) => `${value[0]}/${value[1]}`).join(', ');
|
|
147
|
-
}
|
|
145
|
+
'description': (values) => joinMapped(values, getRationalText, ', ')
|
|
148
146
|
},
|
|
149
147
|
0x0141: 'HalftoneHints',
|
|
150
148
|
0x0142: 'TileWidth',
|
|
@@ -152,35 +150,27 @@ export default {
|
|
|
152
150
|
0x014a: 'A100DataOffset',
|
|
153
151
|
0x014c: {
|
|
154
152
|
name: 'InkSet',
|
|
155
|
-
description: (value) => ({
|
|
153
|
+
description: (value) => getTableDescription({
|
|
156
154
|
1: 'CMYK',
|
|
157
155
|
2: 'Not CMYK'
|
|
158
|
-
})
|
|
156
|
+
}, value)
|
|
159
157
|
},
|
|
160
158
|
0x0151: 'TargetPrinter',
|
|
161
159
|
0x0152: {
|
|
162
160
|
name: 'ExtraSamples',
|
|
163
|
-
description: (value) => ({
|
|
161
|
+
description: (value) => getTableDescription({
|
|
164
162
|
0: 'Unspecified',
|
|
165
163
|
1: 'Associated Alpha',
|
|
166
164
|
2: 'Unassociated Alpha',
|
|
167
|
-
})
|
|
165
|
+
}, value)
|
|
168
166
|
},
|
|
169
167
|
0x0153: {
|
|
170
168
|
name: 'SampleFormat',
|
|
171
169
|
description: (value) => {
|
|
172
|
-
const formats = {
|
|
173
|
-
1: 'Unsigned',
|
|
174
|
-
2: 'Signed',
|
|
175
|
-
3: 'Float',
|
|
176
|
-
4: 'Undefined',
|
|
177
|
-
5: 'Complex int',
|
|
178
|
-
6: 'Complex float',
|
|
179
|
-
};
|
|
180
170
|
if (!Array.isArray(value)) {
|
|
181
|
-
return
|
|
171
|
+
return getSampleFormatText(value);
|
|
182
172
|
}
|
|
183
|
-
return value.map(
|
|
173
|
+
return value.map(getSampleFormatText).join(', ');
|
|
184
174
|
}
|
|
185
175
|
},
|
|
186
176
|
0x0201: 'JPEGInterchangeFormat',
|
|
@@ -274,10 +264,10 @@ export default {
|
|
|
274
264
|
0xc633: 'ShadowScale',
|
|
275
265
|
0xc635: {
|
|
276
266
|
name: 'MakerNoteSafety',
|
|
277
|
-
description: (value) => ({
|
|
267
|
+
description: (value) => getTableDescription({
|
|
278
268
|
0: 'Unsafe',
|
|
279
269
|
1: 'Safe'
|
|
280
|
-
})
|
|
270
|
+
}, value)
|
|
281
271
|
},
|
|
282
272
|
0xc65a: {
|
|
283
273
|
name: 'CalibrationIlluminant1',
|
|
@@ -309,12 +299,12 @@ export default {
|
|
|
309
299
|
0xc6fc: 'ProfileToneCurve',
|
|
310
300
|
0xc6fd: {
|
|
311
301
|
name: 'ProfileEmbedPolicy',
|
|
312
|
-
description: (value) => ({
|
|
302
|
+
description: (value) => getTableDescription({
|
|
313
303
|
0: 'Allow Copying',
|
|
314
304
|
1: 'Embed if Used',
|
|
315
305
|
2: 'Never Embed',
|
|
316
306
|
3: 'No Restrictions'
|
|
317
|
-
})
|
|
307
|
+
}, value)
|
|
318
308
|
},
|
|
319
309
|
0xc6fe: 'ProfileCopyright',
|
|
320
310
|
0xc714: 'ForwardMatrix1',
|
|
@@ -325,12 +315,12 @@ export default {
|
|
|
325
315
|
0xc719: 'PreviewSettingsDigest',
|
|
326
316
|
0xc71a: {
|
|
327
317
|
name: 'PreviewColorSpace',
|
|
328
|
-
description: (value) => ({
|
|
318
|
+
description: (value) => getTableDescription({
|
|
329
319
|
1: 'Gray Gamma 2.2',
|
|
330
320
|
2: 'sRGB',
|
|
331
321
|
3: 'Adobe RGB',
|
|
332
322
|
4: 'ProPhoto RGB'
|
|
333
|
-
})
|
|
323
|
+
}, value)
|
|
334
324
|
},
|
|
335
325
|
0xc71b: 'PreviewDateTime',
|
|
336
326
|
0xc71c: 'RawImageDigest',
|
|
@@ -347,30 +337,49 @@ export default {
|
|
|
347
337
|
0xc7a1: 'CameraLabel',
|
|
348
338
|
0xc7a3: {
|
|
349
339
|
name: 'ProfileHueSatMapEncoding',
|
|
350
|
-
description: (value) => ({
|
|
340
|
+
description: (value) => getTableDescription({
|
|
351
341
|
0: 'Linear',
|
|
352
342
|
1: 'sRGB'
|
|
353
|
-
})
|
|
343
|
+
}, value)
|
|
354
344
|
},
|
|
355
345
|
0xc7a4: {
|
|
356
346
|
name: 'ProfileLookTableEncoding',
|
|
357
|
-
description: (value) => ({
|
|
347
|
+
description: (value) => getTableDescription({
|
|
358
348
|
0: 'Linear',
|
|
359
349
|
1: 'sRGB'
|
|
360
|
-
})
|
|
350
|
+
}, value)
|
|
361
351
|
},
|
|
362
352
|
0xc7a5: 'BaselineExposureOffset',
|
|
363
353
|
0xc7a6: {
|
|
364
354
|
name: 'DefaultBlackRender',
|
|
365
|
-
description: (value) => ({
|
|
355
|
+
description: (value) => getTableDescription({
|
|
366
356
|
0: 'Auto',
|
|
367
357
|
1: 'None'
|
|
368
|
-
})
|
|
358
|
+
}, value)
|
|
369
359
|
},
|
|
370
360
|
0xc7a7: 'NewRawImageDigest',
|
|
371
361
|
0xc7a8: 'RawToPreviewGain'
|
|
372
362
|
};
|
|
373
363
|
|
|
364
|
+
function getRationalText(value) {
|
|
365
|
+
if (!Array.isArray(value)) {
|
|
366
|
+
throw new TypeError('Expected a rational.');
|
|
367
|
+
}
|
|
368
|
+
return `${value[0]}/${value[1]}`;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function getSampleFormatText(sample) {
|
|
372
|
+
const formats = {
|
|
373
|
+
1: 'Unsigned',
|
|
374
|
+
2: 'Signed',
|
|
375
|
+
3: 'Float',
|
|
376
|
+
4: 'Undefined',
|
|
377
|
+
5: 'Complex int',
|
|
378
|
+
6: 'Complex float',
|
|
379
|
+
};
|
|
380
|
+
return getTableDescription(formats, sample);
|
|
381
|
+
}
|
|
382
|
+
|
|
374
383
|
function decodeXPValue(value) {
|
|
375
384
|
if (!Array.isArray(value)) {
|
|
376
385
|
// A one-element value arrives as a bare number, which Uint8Array would take as a length.
|