exifreader 4.48.0 → 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 +66 -46
- package/dist/exif-reader.js +1 -1
- package/dist/exif-reader.js.map +1 -1
- package/exif-reader.d.ts +6 -6
- package/package.json +5 -5
- package/src/canon-tags.js +4 -3
- package/src/exif-reader.js +247 -166
- package/src/icc-tag-names.js +2 -11
- package/src/image-header-iso-bmff.js +261 -39
- package/src/image-header-jxl.js +6 -6
- package/src/image-header-png.js +1 -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/photoshop-tags.js +9 -1
- package/src/png-text-tags.js +94 -52
- package/src/tag-decoder.js +3 -3
- package/src/tag-filter-config.js +23 -0
- package/src/tag-names-0th-ifd.js +51 -42
- package/src/tag-names-common.js +19 -15
- package/src/tag-names-exif-ifd.js +38 -17
- package/src/tag-names-interoperability-ifd.js +2 -2
- package/src/tag-names-mpf-ifd.js +2 -2
- package/src/tag-names-utils.js +38 -3
- package/src/tags-helpers.js +20 -0
- package/src/utils.js +102 -16
- package/src/xmp-tag-names.js +1 -1
- package/src/xmp-tags.js +9 -6
package/exif-reader.d.ts
CHANGED
|
@@ -329,7 +329,7 @@ interface PhotoshopTags {
|
|
|
329
329
|
}
|
|
330
330
|
|
|
331
331
|
interface CanonTags {
|
|
332
|
-
AutoRotate
|
|
332
|
+
AutoRotate?: {
|
|
333
333
|
value: number;
|
|
334
334
|
description: 'None' | 'Rotate 90 CW' | 'Rotate 180' | 'Rotate 270 CW' | 'Unknown';
|
|
335
335
|
};
|
|
@@ -344,23 +344,23 @@ interface CanonTags {
|
|
|
344
344
|
}
|
|
345
345
|
|
|
346
346
|
interface PentaxTags {
|
|
347
|
-
PentaxVersion
|
|
347
|
+
PentaxVersion?: {
|
|
348
348
|
value: number[];
|
|
349
349
|
description: string;
|
|
350
350
|
};
|
|
351
|
-
PentaxModelID
|
|
351
|
+
PentaxModelID?: {
|
|
352
352
|
value: number;
|
|
353
353
|
description: string;
|
|
354
354
|
};
|
|
355
|
-
|
|
355
|
+
CameraOrientation?: {
|
|
356
356
|
value: number;
|
|
357
357
|
description: 'Horizontal (normal)' | 'Rotate 270 CW' | 'Rotate 180' | 'Rotate 90 CW' | 'Upwards' | 'Downwards' | 'Unknown';
|
|
358
358
|
};
|
|
359
|
-
RollAngle
|
|
359
|
+
RollAngle?: {
|
|
360
360
|
value: number;
|
|
361
361
|
description: string;
|
|
362
362
|
};
|
|
363
|
-
PitchAngle
|
|
363
|
+
PitchAngle?: {
|
|
364
364
|
value: number;
|
|
365
365
|
description: string;
|
|
366
366
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "exifreader",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.49.0",
|
|
4
4
|
"description": "Library that parses Exif metadata in images.",
|
|
5
5
|
"author": "Mattias Wallander <mattias@wallander.eu>",
|
|
6
6
|
"repository": {
|
|
@@ -32,18 +32,18 @@
|
|
|
32
32
|
"@babel/preset-env": "^7.29.7",
|
|
33
33
|
"@cypress/webpack-preprocessor": "^8.0.0",
|
|
34
34
|
"@eslint/js": "^9.39.5",
|
|
35
|
-
"@types/node": "^26.6.
|
|
35
|
+
"@types/node": "^26.6.4",
|
|
36
36
|
"babel-loader": "^10.0.0",
|
|
37
37
|
"c8": "^12.0.0",
|
|
38
38
|
"chai": "^6.2.2",
|
|
39
39
|
"cross-env": "^10.0.0",
|
|
40
|
-
"cypress": "^16.1.
|
|
40
|
+
"cypress": "^16.1.1",
|
|
41
41
|
"eslint": "^9.39.4",
|
|
42
42
|
"eslint-plugin-cypress": "^6.4.4",
|
|
43
|
-
"globals": "^17.
|
|
43
|
+
"globals": "^17.13.0",
|
|
44
44
|
"husky": "^9.0.11",
|
|
45
45
|
"linkedom": "^0.18.13",
|
|
46
|
-
"mocha": "^12.0.
|
|
46
|
+
"mocha": "^12.0.3",
|
|
47
47
|
"npm-run-all2": "^9.0.3",
|
|
48
48
|
"rimraf": "^5.0.5",
|
|
49
49
|
"string-replace-loader": "^3.1.0",
|
package/src/canon-tags.js
CHANGED
|
@@ -60,10 +60,11 @@ function read(
|
|
|
60
60
|
function parseShotInfo(shotInfoData) {
|
|
61
61
|
const tags = {};
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
const autoRotate = shotInfoData[SHOT_INFO_AUTO_ROTATE];
|
|
64
|
+
if (Number.isFinite(autoRotate)) {
|
|
64
65
|
tags['AutoRotate'] = {
|
|
65
|
-
value:
|
|
66
|
-
description: getAutoRotateDescription(
|
|
66
|
+
value: autoRotate,
|
|
67
|
+
description: getAutoRotateDescription(autoRotate)
|
|
67
68
|
};
|
|
68
69
|
}
|
|
69
70
|
|
package/src/exif-reader.js
CHANGED
|
@@ -17,10 +17,11 @@ import ByteOrder from './byte-order.js';
|
|
|
17
17
|
import {getTiffHeaderOffset} from './image-header-iso-bmff.js';
|
|
18
18
|
import ImageHeader from './image-header.js';
|
|
19
19
|
import Tags from './tags.js';
|
|
20
|
-
import {getValueBudget, addDecompressedValueAllowance} from './tags-helpers.js';
|
|
20
|
+
import {getValueBudget, addDecompressedValueAllowance, takeEmbeddedExifThumbnail} from './tags-helpers.js';
|
|
21
21
|
import MpfTags from './mpf-tags.js';
|
|
22
22
|
import FileTags from './file-tags.js';
|
|
23
23
|
import JxlFileTags from './jxl-file-tags.js';
|
|
24
|
+
import IsoBmffFileTags from './iso-bmff-file-tags.js';
|
|
24
25
|
import JfifTags from './jfif-tags.js';
|
|
25
26
|
import IptcTags from './iptc-tags.js';
|
|
26
27
|
import XmpTags from './xmp-tags.js';
|
|
@@ -36,13 +37,19 @@ import GifFileTags from './gif-file-tags.js';
|
|
|
36
37
|
import Thumbnail from './thumbnail.js';
|
|
37
38
|
import Composite from './composite.js';
|
|
38
39
|
import {createTagFilter} from './tag-filter.js';
|
|
39
|
-
import {buildTagsFromMergeSteps, isThenable} from './loadview-pipeline.js';
|
|
40
|
+
import {buildTagsFromMergeSteps, isThenable, EXIF_CARRIED_GROUP_ORDER} from './loadview-pipeline.js';
|
|
40
41
|
import exifErrors from './errors.js';
|
|
41
42
|
|
|
42
43
|
// Brob XMP is bounded by the file size, as brob Exif is, plus room for one JPEG
|
|
43
44
|
// standard XMP segment so that a small file can still carry a typical packet.
|
|
44
45
|
const BROB_XMP_SIZE_PER_INPUT_SIZE = 4;
|
|
45
46
|
const BROB_XMP_SIZE_ALLOWANCE = 64 * 1024;
|
|
47
|
+
// An embedded thumbnail is sliced from a decoded or decompressed view that can be
|
|
48
|
+
// far larger than the file. A real JPEG thumbnail shrinks only a little when
|
|
49
|
+
// compressed, so bound the embedded thumbnails of a file by twice its size in
|
|
50
|
+
// total, plus room for a typical thumbnail.
|
|
51
|
+
const EMBEDDED_THUMBNAIL_SIZE_PER_INPUT_SIZE = 2;
|
|
52
|
+
const EMBEDDED_THUMBNAIL_SIZE_ALLOWANCE = 64 * 1024;
|
|
46
53
|
|
|
47
54
|
export default {
|
|
48
55
|
load,
|
|
@@ -110,6 +117,7 @@ export function loadView(
|
|
|
110
117
|
let thumbnailIfdTags = undefined;
|
|
111
118
|
let valueBudget = undefined;
|
|
112
119
|
let embeddedXmpStepForFlat = undefined;
|
|
120
|
+
let decompressedApplicationNotesSize = 0;
|
|
113
121
|
|
|
114
122
|
const {
|
|
115
123
|
fileType,
|
|
@@ -128,6 +136,8 @@ export function loadView(
|
|
|
128
136
|
brobExifChunk,
|
|
129
137
|
brobXmpChunk,
|
|
130
138
|
jxlCodestreamOffset,
|
|
139
|
+
imageDimensionsOffset,
|
|
140
|
+
pixelInformationOffset,
|
|
131
141
|
metadataBlocks,
|
|
132
142
|
metadataTruncated,
|
|
133
143
|
exifDataView,
|
|
@@ -211,51 +221,27 @@ export function loadView(
|
|
|
211
221
|
const parsedExifTags = filterTagsForParse('exif', readTags, tagFilter);
|
|
212
222
|
parsedGroups.exif = parsedExifTags;
|
|
213
223
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
);
|
|
227
|
-
const parsedIptcTags =
|
|
228
|
-
filterTagsForParse('iptc', readIptcTags, tagFilter);
|
|
229
|
-
parsedGroups.iptc = parsedIptcTags;
|
|
230
|
-
|
|
231
|
-
if (tagFilter.shouldReturnGroup('iptc')) {
|
|
232
|
-
mergeSteps.push({
|
|
233
|
-
type: 'mergeGroupAssign',
|
|
234
|
-
groupKey: 'iptc',
|
|
235
|
-
parsedTags: parsedIptcTags,
|
|
236
|
-
});
|
|
224
|
+
const carriedGroups = readExifCarriedGroups(
|
|
225
|
+
parsedExifTags,
|
|
226
|
+
exifDataView || dataView,
|
|
227
|
+
tiffHeaderOffset,
|
|
228
|
+
byteOrder,
|
|
229
|
+
valueBudget,
|
|
230
|
+
{decompressed: false, hasIptcBlock: iptcDataOffset !== undefined}
|
|
231
|
+
);
|
|
232
|
+
for (let i = 0; i < EXIF_CARRIED_GROUP_ORDER.length; i++) {
|
|
233
|
+
const groupKey = EXIF_CARRIED_GROUP_ORDER[i];
|
|
234
|
+
if (carriedGroups[groupKey] === undefined) {
|
|
235
|
+
continue;
|
|
237
236
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
&& Array.isArray(parsedExifTags['ApplicationNotes'].value)
|
|
244
|
-
&& !hasXmpData(xmpChunks)
|
|
245
|
-
&& tagFilter.shouldParseGroup('xmp')
|
|
246
|
-
) {
|
|
247
|
-
const readXmpTags = XmpTags.read(
|
|
248
|
-
getByteString(parsedExifTags['ApplicationNotes'].value),
|
|
249
|
-
undefined,
|
|
250
|
-
domParser
|
|
251
|
-
);
|
|
252
|
-
const parsedXmpTags = filterTagsForParse('xmp', readXmpTags, tagFilter);
|
|
253
|
-
parsedGroups.xmp = parsedXmpTags;
|
|
254
|
-
|
|
255
|
-
if (tagFilter.shouldReturnGroup('xmp')) {
|
|
237
|
+
parsedGroups[groupKey] = carriedGroups[groupKey];
|
|
238
|
+
if (!tagFilter.shouldReturnGroup(groupKey)) {
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
if (groupKey === 'xmp') {
|
|
256
242
|
const step = {
|
|
257
243
|
type: 'mergeXmpGroupAssign',
|
|
258
|
-
parsedTags:
|
|
244
|
+
parsedTags: carriedGroups.xmp,
|
|
259
245
|
};
|
|
260
246
|
|
|
261
247
|
if (expanded) {
|
|
@@ -263,110 +249,15 @@ export function loadView(
|
|
|
263
249
|
} else {
|
|
264
250
|
embeddedXmpStepForFlat = step;
|
|
265
251
|
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
if (
|
|
270
|
-
Constants.USE_PHOTOSHOP
|
|
271
|
-
&& parsedExifTags['ImageSourceData']
|
|
272
|
-
&& parsedExifTags['PhotoshopSettings']
|
|
273
|
-
&& Array.isArray(parsedExifTags['PhotoshopSettings'].value)
|
|
274
|
-
&& tagFilter.shouldParseGroup('photoshop')
|
|
275
|
-
) {
|
|
276
|
-
const readPhotoshopTags = PhotoshopTags.read(
|
|
277
|
-
parsedExifTags['PhotoshopSettings'].value,
|
|
278
|
-
includeUnknown,
|
|
279
|
-
tagFilter
|
|
280
|
-
);
|
|
281
|
-
const parsedPhotoshopTags =
|
|
282
|
-
filterTagsForParse('photoshop', readPhotoshopTags, tagFilter);
|
|
283
|
-
parsedGroups.photoshop = parsedPhotoshopTags;
|
|
284
|
-
|
|
285
|
-
if (tagFilter.shouldReturnGroup('photoshop')) {
|
|
286
|
-
mergeSteps.push({
|
|
287
|
-
type: 'mergeGroupAssign',
|
|
288
|
-
groupKey: 'photoshop',
|
|
289
|
-
parsedTags: parsedPhotoshopTags,
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
if (
|
|
295
|
-
Constants.USE_ICC
|
|
296
|
-
&& parsedExifTags['ICC_Profile']
|
|
297
|
-
&& !hasIccData(iccChunks)
|
|
298
|
-
&& tagFilter.shouldParseGroup('icc')
|
|
299
|
-
) {
|
|
300
|
-
const readIccTags = IccTags.read(
|
|
301
|
-
parsedExifTags['ICC_Profile'].value,
|
|
302
|
-
[{
|
|
303
|
-
offset: 0,
|
|
304
|
-
length: parsedExifTags['ICC_Profile'].value.length,
|
|
305
|
-
chunkNumber: 1,
|
|
306
|
-
chunksTotal: 1
|
|
307
|
-
}]
|
|
308
|
-
);
|
|
309
|
-
const parsedIccTags = filterTagsForParse('icc', readIccTags, tagFilter);
|
|
310
|
-
parsedGroups.icc = parsedIccTags;
|
|
311
|
-
|
|
312
|
-
if (tagFilter.shouldReturnGroup('icc')) {
|
|
252
|
+
} else {
|
|
313
253
|
mergeSteps.push({
|
|
314
254
|
type: 'mergeGroupAssign',
|
|
315
|
-
groupKey
|
|
316
|
-
parsedTags:
|
|
255
|
+
groupKey,
|
|
256
|
+
parsedTags: carriedGroups[groupKey],
|
|
317
257
|
});
|
|
318
258
|
}
|
|
319
259
|
}
|
|
320
260
|
|
|
321
|
-
if (
|
|
322
|
-
Constants.USE_MAKER_NOTES
|
|
323
|
-
&& parsedExifTags['MakerNote']
|
|
324
|
-
&& tagFilter.shouldParseGroup('makerNotes')
|
|
325
|
-
) {
|
|
326
|
-
if (hasCanonData(parsedExifTags)) {
|
|
327
|
-
const readCanonTags = CanonTags.read(
|
|
328
|
-
exifDataView || dataView,
|
|
329
|
-
tiffHeaderOffset,
|
|
330
|
-
parsedExifTags['MakerNote'].__offset,
|
|
331
|
-
byteOrder,
|
|
332
|
-
includeUnknown,
|
|
333
|
-
computed,
|
|
334
|
-
tagFilter,
|
|
335
|
-
valueBudget
|
|
336
|
-
);
|
|
337
|
-
parsedGroups.makerNotes = readCanonTags;
|
|
338
|
-
if (tagFilter.shouldReturnGroup('makerNotes')) {
|
|
339
|
-
mergeSteps.push({
|
|
340
|
-
type: 'mergeGroupAssign',
|
|
341
|
-
groupKey: 'makerNotes',
|
|
342
|
-
parsedTags: readCanonTags,
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
} else if (hasPentaxType1Data(parsedExifTags)) {
|
|
346
|
-
const readPentaxTags = PentaxTags.read(
|
|
347
|
-
exifDataView || dataView,
|
|
348
|
-
tiffHeaderOffset,
|
|
349
|
-
parsedExifTags['MakerNote'].__offset,
|
|
350
|
-
includeUnknown,
|
|
351
|
-
computed,
|
|
352
|
-
tagFilter,
|
|
353
|
-
valueBudget
|
|
354
|
-
);
|
|
355
|
-
parsedGroups.makerNotes = readPentaxTags;
|
|
356
|
-
if (tagFilter.shouldReturnGroup('makerNotes')) {
|
|
357
|
-
mergeSteps.push({
|
|
358
|
-
type: 'mergeGroupAssign',
|
|
359
|
-
groupKey: 'makerNotes',
|
|
360
|
-
parsedTags: readPentaxTags,
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
if (parsedExifTags['MakerNote']) {
|
|
367
|
-
delete parsedExifTags['MakerNote'].__offset;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
261
|
if (tagFilter.shouldReturnGroup('exif')) {
|
|
371
262
|
mergeSteps.push({
|
|
372
263
|
type: 'mergeGroupAssign',
|
|
@@ -421,6 +312,8 @@ export function loadView(
|
|
|
421
312
|
}
|
|
422
313
|
}
|
|
423
314
|
|
|
315
|
+
const readEmbeddedExifThumbnail = getEmbeddedExifThumbnailReader(tagFilter, dataView);
|
|
316
|
+
|
|
424
317
|
if (
|
|
425
318
|
Constants.USE_JXL
|
|
426
319
|
&& Constants.USE_EXIF
|
|
@@ -435,7 +328,7 @@ export function loadView(
|
|
|
435
328
|
.then((decompressedDataView) => {
|
|
436
329
|
const brobTiffHeaderOffset = getTiffHeaderOffset(decompressedDataView, 0);
|
|
437
330
|
addDecompressedValueAllowance(valueBudget, decompressedDataView.byteLength);
|
|
438
|
-
const {tags: readTags} = Tags.read(
|
|
331
|
+
const {tags: readTags, byteOrder: brobByteOrder} = Tags.read(
|
|
439
332
|
decompressedDataView,
|
|
440
333
|
brobTiffHeaderOffset,
|
|
441
334
|
includeUnknown,
|
|
@@ -443,16 +336,24 @@ export function loadView(
|
|
|
443
336
|
tagFilter,
|
|
444
337
|
valueBudget
|
|
445
338
|
);
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
339
|
+
const thumbnail = takeEmbeddedExifThumbnail(
|
|
340
|
+
readTags,
|
|
341
|
+
decompressedDataView,
|
|
342
|
+
brobTiffHeaderOffset,
|
|
343
|
+
readEmbeddedExifThumbnail
|
|
344
|
+
);
|
|
345
|
+
const carriedGroups = readEmbeddedExifCarriedGroups(
|
|
346
|
+
decompressedDataView,
|
|
347
|
+
readTags,
|
|
348
|
+
brobTiffHeaderOffset,
|
|
349
|
+
brobByteOrder,
|
|
350
|
+
valueBudget,
|
|
351
|
+
{decompressed: true, hasIptcBlock: false}
|
|
352
|
+
);
|
|
353
|
+
deferredResults.brobExif = {exifTags: readTags, carriedGroups, thumbnail};
|
|
453
354
|
})
|
|
454
355
|
.catch(() => {
|
|
455
|
-
deferredResults.brobExif =
|
|
356
|
+
deferredResults.brobExif = undefined;
|
|
456
357
|
})
|
|
457
358
|
);
|
|
458
359
|
mergeSteps.push({
|
|
@@ -473,7 +374,7 @@ export function loadView(
|
|
|
473
374
|
deferredPromises.push(
|
|
474
375
|
decompress(compressedXmpData, COMPRESSION_METHOD_BROTLI, undefined, 'dataview', decompressConfig)
|
|
475
376
|
.then((decompressedDataView) => {
|
|
476
|
-
if (exceedsBrobXmpSizeBound(decompressedDataView, dataView)) {
|
|
377
|
+
if (exceedsBrobXmpSizeBound(decompressedDataView.byteLength, dataView)) {
|
|
477
378
|
deferredResults.brobXmp = {};
|
|
478
379
|
return;
|
|
479
380
|
}
|
|
@@ -576,7 +477,7 @@ export function loadView(
|
|
|
576
477
|
|| tagFilter.shouldParseGroup('iptc')
|
|
577
478
|
)
|
|
578
479
|
) {
|
|
579
|
-
const {readTags, embeddedExifTags, embeddedIptcTags, embeddedExifThumbnail, readTagsPromise} = PngTextTags.read(
|
|
480
|
+
const {readTags, embeddedExifTags, embeddedIptcTags, embeddedExifThumbnail, exifCarriedGroups, readTagsPromise} = PngTextTags.read(
|
|
580
481
|
dataView,
|
|
581
482
|
pngTextChunks,
|
|
582
483
|
async,
|
|
@@ -585,7 +486,8 @@ export function loadView(
|
|
|
585
486
|
tagFilter,
|
|
586
487
|
decompressConfig,
|
|
587
488
|
valueBudget,
|
|
588
|
-
|
|
489
|
+
readEmbeddedExifThumbnail,
|
|
490
|
+
readEmbeddedExifCarriedGroups
|
|
589
491
|
);
|
|
590
492
|
pngTextIsAsync = !!readTagsPromise;
|
|
591
493
|
|
|
@@ -595,6 +497,7 @@ export function loadView(
|
|
|
595
497
|
embeddedExifTags,
|
|
596
498
|
embeddedIptcTags,
|
|
597
499
|
embeddedExifThumbnail,
|
|
500
|
+
exifCarriedGroups,
|
|
598
501
|
});
|
|
599
502
|
|
|
600
503
|
if (readTagsPromise) {
|
|
@@ -679,6 +582,24 @@ export function loadView(
|
|
|
679
582
|
}
|
|
680
583
|
}
|
|
681
584
|
|
|
585
|
+
if (
|
|
586
|
+
(Constants.USE_HEIC || Constants.USE_AVIF)
|
|
587
|
+
&& (imageDimensionsOffset !== undefined || pixelInformationOffset !== undefined)
|
|
588
|
+
&& tagFilter.shouldParseGroup('file')
|
|
589
|
+
) {
|
|
590
|
+
const readTags = IsoBmffFileTags.read(dataView, imageDimensionsOffset, pixelInformationOffset);
|
|
591
|
+
const parsedIsoBmffFileTags = filterTagsForParse('file', readTags, tagFilter);
|
|
592
|
+
parsedGroups.file = parsedIsoBmffFileTags;
|
|
593
|
+
|
|
594
|
+
if (tagFilter.shouldReturnGroup('file')) {
|
|
595
|
+
mergeSteps.push({
|
|
596
|
+
type: 'mergeGroupAssign',
|
|
597
|
+
groupKey: 'file',
|
|
598
|
+
parsedTags: parsedIsoBmffFileTags,
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
682
603
|
if (Constants.USE_EXIF) {
|
|
683
604
|
mergeSteps.push({type: 'gps'});
|
|
684
605
|
}
|
|
@@ -764,6 +685,140 @@ export function loadView(
|
|
|
764
685
|
}
|
|
765
686
|
return !(Array.isArray(file) && file.length === 1 && file[0] === 'FileType');
|
|
766
687
|
}
|
|
688
|
+
|
|
689
|
+
// Drops MakerNote.__offset once the maker note has been read, even when a
|
|
690
|
+
// reader throws.
|
|
691
|
+
function readExifCarriedGroups(parsedExifTags, exifTiffDataView, exifTiffHeaderOffset, exifByteOrder, exifValueBudget, source) {
|
|
692
|
+
const groups = {};
|
|
693
|
+
|
|
694
|
+
try {
|
|
695
|
+
if (
|
|
696
|
+
Constants.USE_IPTC
|
|
697
|
+
&& parsedExifTags['IPTC-NAA']
|
|
698
|
+
&& !source.hasIptcBlock
|
|
699
|
+
&& tagFilter.shouldParseGroup('iptc')
|
|
700
|
+
) {
|
|
701
|
+
const readIptcTags = IptcTags.read(
|
|
702
|
+
parsedExifTags['IPTC-NAA'].value,
|
|
703
|
+
0,
|
|
704
|
+
includeUnknown,
|
|
705
|
+
tagFilter,
|
|
706
|
+
exifValueBudget
|
|
707
|
+
);
|
|
708
|
+
groups.iptc = filterTagsForParse('iptc', readIptcTags, tagFilter);
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
if (
|
|
712
|
+
Constants.USE_XMP
|
|
713
|
+
&& parsedExifTags['ApplicationNotes']
|
|
714
|
+
&& isNumberArray(parsedExifTags['ApplicationNotes'].value)
|
|
715
|
+
&& !hasXmpData(xmpChunks)
|
|
716
|
+
&& tagFilter.shouldParseGroup('xmp')
|
|
717
|
+
&& (!source.decompressed || takeDecompressedApplicationNotesAllowance(parsedExifTags['ApplicationNotes'].value.length))
|
|
718
|
+
) {
|
|
719
|
+
const readXmpTags = XmpTags.read(
|
|
720
|
+
getByteString(parsedExifTags['ApplicationNotes'].value),
|
|
721
|
+
undefined,
|
|
722
|
+
domParser
|
|
723
|
+
);
|
|
724
|
+
groups.xmp = filterTagsForParse('xmp', readXmpTags, tagFilter);
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
if (
|
|
728
|
+
Constants.USE_PHOTOSHOP
|
|
729
|
+
&& parsedExifTags['ImageSourceData']
|
|
730
|
+
&& parsedExifTags['PhotoshopSettings']
|
|
731
|
+
&& Array.isArray(parsedExifTags['PhotoshopSettings'].value)
|
|
732
|
+
&& tagFilter.shouldParseGroup('photoshop')
|
|
733
|
+
) {
|
|
734
|
+
const readPhotoshopTags = PhotoshopTags.read(
|
|
735
|
+
parsedExifTags['PhotoshopSettings'].value,
|
|
736
|
+
includeUnknown,
|
|
737
|
+
tagFilter
|
|
738
|
+
);
|
|
739
|
+
groups.photoshop = filterTagsForParse('photoshop', readPhotoshopTags, tagFilter);
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
if (
|
|
743
|
+
Constants.USE_ICC
|
|
744
|
+
&& parsedExifTags['ICC_Profile']
|
|
745
|
+
&& !hasIccData(iccChunks)
|
|
746
|
+
&& tagFilter.shouldParseGroup('icc')
|
|
747
|
+
) {
|
|
748
|
+
const readIccTags = IccTags.read(
|
|
749
|
+
parsedExifTags['ICC_Profile'].value,
|
|
750
|
+
[{
|
|
751
|
+
offset: 0,
|
|
752
|
+
length: parsedExifTags['ICC_Profile'].value.length,
|
|
753
|
+
chunkNumber: 1,
|
|
754
|
+
chunksTotal: 1
|
|
755
|
+
}]
|
|
756
|
+
);
|
|
757
|
+
groups.icc = filterTagsForParse('icc', readIccTags, tagFilter);
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
if (
|
|
761
|
+
Constants.USE_MAKER_NOTES
|
|
762
|
+
&& parsedExifTags['MakerNote']
|
|
763
|
+
&& tagFilter.shouldParseGroup('makerNotes')
|
|
764
|
+
) {
|
|
765
|
+
if (hasCanonData(parsedExifTags)) {
|
|
766
|
+
groups.makerNotes = CanonTags.read(
|
|
767
|
+
exifTiffDataView,
|
|
768
|
+
exifTiffHeaderOffset,
|
|
769
|
+
parsedExifTags['MakerNote'].__offset,
|
|
770
|
+
exifByteOrder,
|
|
771
|
+
includeUnknown,
|
|
772
|
+
computed,
|
|
773
|
+
tagFilter,
|
|
774
|
+
exifValueBudget
|
|
775
|
+
);
|
|
776
|
+
} else if (hasPentaxType1Data(parsedExifTags)) {
|
|
777
|
+
groups.makerNotes = PentaxTags.read(
|
|
778
|
+
exifTiffDataView,
|
|
779
|
+
exifTiffHeaderOffset,
|
|
780
|
+
parsedExifTags['MakerNote'].__offset,
|
|
781
|
+
includeUnknown,
|
|
782
|
+
computed,
|
|
783
|
+
tagFilter,
|
|
784
|
+
exifValueBudget
|
|
785
|
+
);
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
} finally {
|
|
789
|
+
if (parsedExifTags['MakerNote']) {
|
|
790
|
+
delete parsedExifTags['MakerNote'].__offset;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
return groups;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
// The brob XMP bound covers the decompressed Exif blocks of a file together,
|
|
798
|
+
// so that several cannot each pass it.
|
|
799
|
+
function takeDecompressedApplicationNotesAllowance(byteLength) {
|
|
800
|
+
if (exceedsBrobXmpSizeBound(decompressedApplicationNotesSize + byteLength, dataView)) {
|
|
801
|
+
return false;
|
|
802
|
+
}
|
|
803
|
+
decompressedApplicationNotesSize += byteLength;
|
|
804
|
+
return true;
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
// A maker note that throws must drop the groups, not the Exif tags already read.
|
|
808
|
+
function readEmbeddedExifCarriedGroups(exifTiffDataView, readTags, exifTiffHeaderOffset, exifByteOrder, exifValueBudget, source) {
|
|
809
|
+
try {
|
|
810
|
+
return readExifCarriedGroups(
|
|
811
|
+
filterTagsForParse('exif', readTags, tagFilter),
|
|
812
|
+
exifTiffDataView,
|
|
813
|
+
exifTiffHeaderOffset,
|
|
814
|
+
exifByteOrder,
|
|
815
|
+
exifValueBudget,
|
|
816
|
+
source
|
|
817
|
+
);
|
|
818
|
+
} catch (error) {
|
|
819
|
+
return {};
|
|
820
|
+
}
|
|
821
|
+
}
|
|
767
822
|
}
|
|
768
823
|
|
|
769
824
|
// A caller-supplied DataView can be a window into a larger buffer. Extractors
|
|
@@ -793,9 +848,8 @@ function isDataViewLike(dataView) {
|
|
|
793
848
|
}
|
|
794
849
|
|
|
795
850
|
function getBrobDataView(dataView, brobChunk) {
|
|
796
|
-
// The box length is untrusted
|
|
797
|
-
//
|
|
798
|
-
// parser never reports a dataOffset past the end of the view.
|
|
851
|
+
// The box length is untrusted, so bound the view by the bytes present. The
|
|
852
|
+
// JXL header parser never reports a dataOffset past the end of the view.
|
|
799
853
|
const length = Math.max(0, Math.min(brobChunk.length, dataView.byteLength - brobChunk.dataOffset));
|
|
800
854
|
if (isDataViewLike(dataView)) {
|
|
801
855
|
return new DataView(dataView.buffer, dataView.byteOffset + brobChunk.dataOffset, length);
|
|
@@ -808,9 +862,8 @@ function getBrobDataView(dataView, brobChunk) {
|
|
|
808
862
|
return new DataView(bytes.buffer);
|
|
809
863
|
}
|
|
810
864
|
|
|
811
|
-
function exceedsBrobXmpSizeBound(
|
|
812
|
-
return
|
|
813
|
-
> BROB_XMP_SIZE_PER_INPUT_SIZE * inputDataView.byteLength + BROB_XMP_SIZE_ALLOWANCE;
|
|
865
|
+
function exceedsBrobXmpSizeBound(byteLength, inputDataView) {
|
|
866
|
+
return byteLength > BROB_XMP_SIZE_PER_INPUT_SIZE * inputDataView.byteLength + BROB_XMP_SIZE_ALLOWANCE;
|
|
814
867
|
}
|
|
815
868
|
|
|
816
869
|
function readExifTagsSafely(dataView, tiffHeaderOffset, includeUnknown, computed, tagFilter) {
|
|
@@ -831,7 +884,7 @@ function readExifTagsSafely(dataView, tiffHeaderOffset, includeUnknown, computed
|
|
|
831
884
|
}
|
|
832
885
|
}
|
|
833
886
|
|
|
834
|
-
function
|
|
887
|
+
function getEmbeddedExifThumbnailReader(tagFilter, inputDataView) {
|
|
835
888
|
if (
|
|
836
889
|
!Constants.USE_EXIF
|
|
837
890
|
|| !Constants.USE_THUMBNAIL
|
|
@@ -839,11 +892,27 @@ function getPngTextThumbnailReader(tagFilter) {
|
|
|
839
892
|
) {
|
|
840
893
|
return undefined;
|
|
841
894
|
}
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
filterTagsForParse('thumbnail', thumbnailIfdTags, tagFilter)
|
|
845
|
-
|
|
846
|
-
|
|
895
|
+
let copiedThumbnailSize = 0;
|
|
896
|
+
return (dataView, thumbnailIfdTags, tiffHeaderOffset) => {
|
|
897
|
+
const parsedThumbnailIfdTags = filterTagsForParse('thumbnail', thumbnailIfdTags, tagFilter);
|
|
898
|
+
const lengthTag = parsedThumbnailIfdTags.JPEGInterchangeFormatLength;
|
|
899
|
+
const sizeBound =
|
|
900
|
+
EMBEDDED_THUMBNAIL_SIZE_PER_INPUT_SIZE * inputDataView.byteLength + EMBEDDED_THUMBNAIL_SIZE_ALLOWANCE;
|
|
901
|
+
if (!hasLengthWithin(lengthTag, sizeBound - copiedThumbnailSize)) {
|
|
902
|
+
return parsedThumbnailIfdTags;
|
|
903
|
+
}
|
|
904
|
+
const thumbnail = Thumbnail.get(dataView, parsedThumbnailIfdTags, tiffHeaderOffset);
|
|
905
|
+
if (thumbnail.image) {
|
|
906
|
+
copiedThumbnailSize += lengthTag.value;
|
|
907
|
+
}
|
|
908
|
+
return thumbnail;
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
function hasLengthWithin(lengthTag, maxLength) {
|
|
913
|
+
return !!lengthTag
|
|
914
|
+
&& typeof lengthTag.value === 'number'
|
|
915
|
+
&& lengthTag.value <= maxLength;
|
|
847
916
|
}
|
|
848
917
|
|
|
849
918
|
function filterTagsForParse(groupKey, readTags, tagFilter) {
|
|
@@ -912,6 +981,8 @@ function hasPotentialMetaData({
|
|
|
912
981
|
vp8xChunkOffset,
|
|
913
982
|
gifHeaderOffset,
|
|
914
983
|
jxlCodestreamOffset,
|
|
984
|
+
imageDimensionsOffset,
|
|
985
|
+
pixelInformationOffset,
|
|
915
986
|
}) {
|
|
916
987
|
return !!fileType
|
|
917
988
|
|| (
|
|
@@ -969,6 +1040,10 @@ function hasPotentialMetaData({
|
|
|
969
1040
|
|| (
|
|
970
1041
|
Constants.USE_JXL
|
|
971
1042
|
&& jxlCodestreamOffset !== undefined
|
|
1043
|
+
)
|
|
1044
|
+
|| (
|
|
1045
|
+
(Constants.USE_HEIC || Constants.USE_AVIF)
|
|
1046
|
+
&& (imageDimensionsOffset !== undefined || pixelInformationOffset !== undefined)
|
|
972
1047
|
);
|
|
973
1048
|
}
|
|
974
1049
|
|
|
@@ -1019,6 +1094,12 @@ function getGpsGroupFromExifTags(exifTags) {
|
|
|
1019
1094
|
return gps;
|
|
1020
1095
|
}
|
|
1021
1096
|
|
|
1097
|
+
// ASCII values hold strings and holes, values of two or more rationals hold
|
|
1098
|
+
// number pairs: neither converts to the character codes of an XMP packet.
|
|
1099
|
+
function isNumberArray(value) {
|
|
1100
|
+
return Array.isArray(value) && typeof value[0] === 'number';
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1022
1103
|
function hasXmpData(xmpChunks) {
|
|
1023
1104
|
return Array.isArray(xmpChunks) && xmpChunks.length > 0;
|
|
1024
1105
|
}
|