exifreader 4.40.5 → 4.41.1
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 +34 -15
- package/babel.config.json +3 -15
- package/bin/build.js +74 -45
- package/bin/cli.js +165 -0
- package/bin/findDependentConfig.js +49 -8
- package/bin/profile.js +4 -4
- package/dist/exif-reader.js +1 -1
- package/dist/exif-reader.js.map +1 -1
- package/package.json +33 -31
- package/src/exif-reader.js +0 -1
- package/src/image-header-iso-bmff-iloc.js +26 -1
- package/src/load-auto.js +1 -1
- package/src/loadview-pipeline.js +17 -13
- package/src/package.json +1 -0
- package/src/photoshop-tag-names.js +0 -927
- package/webpack.config.js +11 -3
- package/bin/.eslintrc.json +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "exifreader",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.41.1",
|
|
4
4
|
"description": "Library that parses Exif metadata in images.",
|
|
5
5
|
"author": "Mattias Wallander <mattias@wallander.eu>",
|
|
6
6
|
"repository": {
|
|
@@ -21,68 +21,70 @@
|
|
|
21
21
|
"webpack.config.js"
|
|
22
22
|
],
|
|
23
23
|
"types": "./exif-reader.d.ts",
|
|
24
|
+
"bin": {
|
|
25
|
+
"exifreader": "bin/cli.js"
|
|
26
|
+
},
|
|
24
27
|
"optionalDependencies": {
|
|
25
28
|
"@xmldom/xmldom": "^0.9.10"
|
|
26
29
|
},
|
|
27
30
|
"devDependencies": {
|
|
28
|
-
"@babel/core": "^7.
|
|
29
|
-
"@babel/preset-env": "^7.29.
|
|
30
|
-
"@
|
|
31
|
-
"@types/node": "^
|
|
31
|
+
"@babel/core": "^7.29.7",
|
|
32
|
+
"@babel/preset-env": "^7.29.7",
|
|
33
|
+
"@eslint/js": "^9.39.5",
|
|
34
|
+
"@types/node": "^26.1.1",
|
|
32
35
|
"babel-loader": "^10.0.0",
|
|
33
|
-
"
|
|
34
|
-
"chai": "^
|
|
36
|
+
"c8": "^11.0.0",
|
|
37
|
+
"chai": "^6.2.2",
|
|
35
38
|
"cross-env": "^10.0.0",
|
|
36
|
-
"cypress": "^15.
|
|
37
|
-
"eslint": "^
|
|
38
|
-
"eslint-plugin-cypress": "^
|
|
39
|
+
"cypress": "^15.18.1",
|
|
40
|
+
"eslint": "^9.39.4",
|
|
41
|
+
"eslint-plugin-cypress": "^6.4.1",
|
|
42
|
+
"globals": "^17.7.0",
|
|
39
43
|
"husky": "^9.0.11",
|
|
40
|
-
"linkedom": "^0.18.
|
|
44
|
+
"linkedom": "^0.18.13",
|
|
41
45
|
"mocha": "^11.7.6",
|
|
42
|
-
"npm-run-
|
|
43
|
-
"nyc": "^18.0.0",
|
|
46
|
+
"npm-run-all2": "^9.0.2",
|
|
44
47
|
"rimraf": "^5.0.5",
|
|
45
48
|
"string-replace-loader": "^3.1.0",
|
|
46
|
-
"terser-webpack-plugin": "^5.6.
|
|
47
|
-
"typescript": "^
|
|
48
|
-
"webpack": "5.
|
|
49
|
-
"webpack-cli": "^7.
|
|
50
|
-
"webpack-dev-server": "^5.2.
|
|
49
|
+
"terser-webpack-plugin": "^5.6.1",
|
|
50
|
+
"typescript": "^7.0.2",
|
|
51
|
+
"webpack": "5.108.4",
|
|
52
|
+
"webpack-cli": "^7.2.1",
|
|
53
|
+
"webpack-dev-server": "^5.2.6"
|
|
51
54
|
},
|
|
52
55
|
"scripts": {
|
|
53
56
|
"build": "node bin/build.js",
|
|
54
57
|
"build:pages": "node bin/build-pages.js",
|
|
55
|
-
"coverage": "
|
|
58
|
+
"coverage": "c8 npm test",
|
|
56
59
|
"cypress:open": "cypress open --e2e",
|
|
57
60
|
"lint": "eslint .",
|
|
58
61
|
"start": "cross-env NODE_ENV=development webpack serve",
|
|
59
|
-
"test": "
|
|
60
|
-
"test:integration": "
|
|
62
|
+
"test": "mocha --recursive \"test/unit/\"",
|
|
63
|
+
"test:integration": "mocha \"test/integration/**/*-spec.js\"",
|
|
61
64
|
"test:integration:update": "node test/integration/update.js",
|
|
62
|
-
"test:build": "mocha test/build/test.js",
|
|
65
|
+
"test:build": "mocha test/build/test.js test/build/packaging.js",
|
|
63
66
|
"test:build:custom": "mocha --bail test/build/test-custom.js",
|
|
64
67
|
"test:build:update": "node test/build/update.js",
|
|
65
68
|
"test:e2e:chrome": "cypress run",
|
|
66
69
|
"test:e2e:firefox": "cypress run --browser firefox",
|
|
67
70
|
"test:types": "tsc --noEmit --project test/types",
|
|
68
|
-
"test:all": "npm-run-
|
|
69
|
-
"pre-commit": "npm-run-
|
|
71
|
+
"test:all": "npm-run-all2 lint test:types coverage test:e2e:chrome test:integration test:build test:build:custom",
|
|
72
|
+
"pre-commit": "npm-run-all2 lint test:types coverage test:build",
|
|
70
73
|
"postinstall": "node bin/build.js --only-with-config",
|
|
71
74
|
"prepare": "husky"
|
|
72
75
|
},
|
|
73
|
-
"
|
|
76
|
+
"c8": {
|
|
74
77
|
"check-coverage": true,
|
|
75
|
-
"statements":
|
|
76
|
-
"branches":
|
|
77
|
-
"functions":
|
|
78
|
-
"lines":
|
|
78
|
+
"statements": 93,
|
|
79
|
+
"branches": 90,
|
|
80
|
+
"functions": 98,
|
|
81
|
+
"lines": 93,
|
|
79
82
|
"reporter": [
|
|
80
83
|
"lcov",
|
|
81
84
|
"text"
|
|
82
85
|
],
|
|
83
86
|
"exclude": [
|
|
84
|
-
"test
|
|
85
|
-
"**/node_modules/*"
|
|
87
|
+
"test/**"
|
|
86
88
|
]
|
|
87
89
|
},
|
|
88
90
|
"browserslist": [
|
package/src/exif-reader.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import {get64BitValue} from './image-header-iso-bmff-utils.js';
|
|
2
2
|
|
|
3
|
+
// Absolute backstop on the number of extent objects a single iloc box may
|
|
4
|
+
// allocate, guarding against memory exhaustion from a crafted file
|
|
5
|
+
// (GHSA-pj96-35fp-cfcc). It is far above any legitimate file.
|
|
6
|
+
const MAX_TOTAL_EXTENTS = 1024 * 1024;
|
|
7
|
+
|
|
3
8
|
export function parseItemLocationBox(dataView, version, contentOffset, boxLength) {
|
|
4
9
|
const FLAGS_SIZE = 3;
|
|
5
10
|
|
|
@@ -83,8 +88,13 @@ function getItems(dataView, version, offsets, sizes, offsetSize, lengthSize, ind
|
|
|
83
88
|
|
|
84
89
|
const items = [];
|
|
85
90
|
let offset = offsets.items;
|
|
91
|
+
const extentByteSize = sizes.item.extent.extentIndex + sizes.item.extent.extentOffset + sizes.item.extent.extentLength;
|
|
92
|
+
let totalExtents = 0;
|
|
86
93
|
|
|
87
94
|
for (let i = 0; i < itemCount; i++) {
|
|
95
|
+
if (offset >= dataView.byteLength) {
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
88
98
|
const item = {extents: []};
|
|
89
99
|
item.itemId = getItemId(dataView, offset, version);
|
|
90
100
|
offset += sizes.item.itemId;
|
|
@@ -96,7 +106,8 @@ function getItems(dataView, version, offsets, sizes, offsetSize, lengthSize, ind
|
|
|
96
106
|
offset += sizes.item.baseOffset;
|
|
97
107
|
item.extentCount = dataView.getUint16(offset);
|
|
98
108
|
offset += sizes.item.extentCount;
|
|
99
|
-
|
|
109
|
+
const extentCount = getBoundedExtentCount(item.extentCount, extentByteSize, offset, dataView.byteLength, MAX_TOTAL_EXTENTS - totalExtents);
|
|
110
|
+
for (let j = 0; j < extentCount; j++) {
|
|
100
111
|
const extent = {};
|
|
101
112
|
|
|
102
113
|
extent.extentIndex = getExtentIndex(dataView, version, offset, indexSize);
|
|
@@ -108,6 +119,7 @@ function getItems(dataView, version, offsets, sizes, offsetSize, lengthSize, ind
|
|
|
108
119
|
|
|
109
120
|
item.extents.push(extent);
|
|
110
121
|
}
|
|
122
|
+
totalExtents += extentCount;
|
|
111
123
|
|
|
112
124
|
items.push(item);
|
|
113
125
|
}
|
|
@@ -115,6 +127,19 @@ function getItems(dataView, version, offsets, sizes, offsetSize, lengthSize, ind
|
|
|
115
127
|
return items;
|
|
116
128
|
}
|
|
117
129
|
|
|
130
|
+
// An extent whose size fields are all zero occupies no bytes and carries no
|
|
131
|
+
// location, so it cannot be substantiated by the buffer and none are produced
|
|
132
|
+
// (GHSA-pj96-35fp-cfcc). Otherwise the count is limited by the bytes left in
|
|
133
|
+
// the buffer and by an absolute backstop, keeping allocation proportional to
|
|
134
|
+
// the input size.
|
|
135
|
+
function getBoundedExtentCount(declaredCount, extentByteSize, offset, byteLength, remainingBudget) {
|
|
136
|
+
if (extentByteSize === 0) {
|
|
137
|
+
return 0;
|
|
138
|
+
}
|
|
139
|
+
const fitInBuffer = Math.floor((byteLength - offset) / extentByteSize);
|
|
140
|
+
return Math.max(0, Math.min(declaredCount, fitInBuffer, remainingBudget));
|
|
141
|
+
}
|
|
142
|
+
|
|
118
143
|
function getItemId(dataView, offset, version) {
|
|
119
144
|
if (version < 2) {
|
|
120
145
|
return dataView.getUint16(offset);
|
package/src/load-auto.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
3
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
4
|
|
|
5
|
-
/* global Buffer
|
|
5
|
+
/* global Buffer */
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
fetchRange, nodeGetRange, readLocalFileRange, readFileObjectRange,
|
package/src/loadview-pipeline.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
3
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
4
|
|
|
5
|
+
import Constants from './constants.js';
|
|
6
|
+
|
|
5
7
|
export function buildTagsFromMergeSteps({
|
|
6
8
|
mergeSteps,
|
|
7
9
|
deferredResults,
|
|
@@ -37,7 +39,8 @@ export function buildTagsFromMergeSteps({
|
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
if (
|
|
40
|
-
|
|
42
|
+
Constants.USE_PNG
|
|
43
|
+
&& expanded
|
|
41
44
|
&& pngTextIsAsync
|
|
42
45
|
&& tagFilter.shouldReturnGroup('png')
|
|
43
46
|
&& tags.png
|
|
@@ -46,7 +49,8 @@ export function buildTagsFromMergeSteps({
|
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
if (
|
|
49
|
-
|
|
52
|
+
Constants.USE_PNG
|
|
53
|
+
&& expanded
|
|
50
54
|
&& tagFilter.shouldReturnGroup('png')
|
|
51
55
|
&& deps.hasPngTextData(pngTextChunks)
|
|
52
56
|
&& tags.png
|
|
@@ -86,7 +90,7 @@ export function applyMergeStep({
|
|
|
86
90
|
return mergeMergeGroup(tags, step.groupKey, returnedTags, expanded, deps);
|
|
87
91
|
}
|
|
88
92
|
|
|
89
|
-
if (step.type === 'mergeXmpGroupAssign') {
|
|
93
|
+
if (Constants.USE_XMP && step.type === 'mergeXmpGroupAssign') {
|
|
90
94
|
const returnedTags =
|
|
91
95
|
deps.filterTagsForReturn('xmp', step.parsedTags, tagFilter);
|
|
92
96
|
|
|
@@ -102,7 +106,7 @@ export function applyMergeStep({
|
|
|
102
106
|
return deps.objectAssign({}, tags, returnedTagsForFlat);
|
|
103
107
|
}
|
|
104
108
|
|
|
105
|
-
if (step.type === 'mergeIccDeferred') {
|
|
109
|
+
if (Constants.USE_ICC && step.type === 'mergeIccDeferred') {
|
|
106
110
|
const resolvedReadTags = deferredResults[step.deferredKey];
|
|
107
111
|
const parsedIccTags =
|
|
108
112
|
deps.filterTagsForParse('icc', resolvedReadTags, tagFilter);
|
|
@@ -118,7 +122,7 @@ export function applyMergeStep({
|
|
|
118
122
|
return mergeAssignGroup(tags, 'icc', returnedIccTags, expanded, deps);
|
|
119
123
|
}
|
|
120
124
|
|
|
121
|
-
if (step.type === 'mergeBrobExifDeferred') {
|
|
125
|
+
if (Constants.USE_JXL && step.type === 'mergeBrobExifDeferred') {
|
|
122
126
|
const resolvedReadTags = deferredResults[step.deferredKey];
|
|
123
127
|
if (!resolvedReadTags || Object.keys(resolvedReadTags).length === 0) {
|
|
124
128
|
return tags;
|
|
@@ -137,7 +141,7 @@ export function applyMergeStep({
|
|
|
137
141
|
return mergeAssignGroup(tags, 'exif', returnedTags, expanded, deps);
|
|
138
142
|
}
|
|
139
143
|
|
|
140
|
-
if (step.type === 'mergeBrobXmpDeferred') {
|
|
144
|
+
if (Constants.USE_JXL && step.type === 'mergeBrobXmpDeferred') {
|
|
141
145
|
const resolvedReadTags = deferredResults[step.deferredKey];
|
|
142
146
|
if (!resolvedReadTags || Object.keys(resolvedReadTags).length === 0) {
|
|
143
147
|
return tags;
|
|
@@ -164,7 +168,7 @@ export function applyMergeStep({
|
|
|
164
168
|
return deps.objectAssign({}, tags, returnedTagsForFlat);
|
|
165
169
|
}
|
|
166
170
|
|
|
167
|
-
if (step.type === 'mergePngFile') {
|
|
171
|
+
if (Constants.USE_PNG && step.type === 'mergePngFile') {
|
|
168
172
|
const returnedPngFileTags =
|
|
169
173
|
deps.filterTagsForReturn('png', step.parsedTags, tagFilter);
|
|
170
174
|
|
|
@@ -186,7 +190,7 @@ export function applyMergeStep({
|
|
|
186
190
|
return deps.objectAssign({}, tags, returnedPngFileTags);
|
|
187
191
|
}
|
|
188
192
|
|
|
189
|
-
if (step.type === 'mergePngChunk') {
|
|
193
|
+
if (Constants.USE_PNG && step.type === 'mergePngChunk') {
|
|
190
194
|
const returnedPngChunkTags =
|
|
191
195
|
deps.filterTagsForReturn('png', step.parsedTags, tagFilter);
|
|
192
196
|
|
|
@@ -207,7 +211,7 @@ export function applyMergeStep({
|
|
|
207
211
|
return deps.objectAssign({}, tags, returnedPngChunkTags);
|
|
208
212
|
}
|
|
209
213
|
|
|
210
|
-
if (step.type === 'processPngTextReadTags') {
|
|
214
|
+
if (Constants.USE_PNG && step.type === 'processPngTextReadTags') {
|
|
211
215
|
return addPngTextReadTagsToTagsAndGroups({
|
|
212
216
|
readTags: step.readTags,
|
|
213
217
|
parsedGroups,
|
|
@@ -218,7 +222,7 @@ export function applyMergeStep({
|
|
|
218
222
|
});
|
|
219
223
|
}
|
|
220
224
|
|
|
221
|
-
if (step.type === 'processPngTextReadTagsDeferredList') {
|
|
225
|
+
if (Constants.USE_PNG && step.type === 'processPngTextReadTagsDeferredList') {
|
|
222
226
|
const tagList = deferredResults[step.deferredKey] || [];
|
|
223
227
|
|
|
224
228
|
for (let i = 0; i < tagList.length; i++) {
|
|
@@ -304,9 +308,9 @@ export function applyMergeStep({
|
|
|
304
308
|
parsedGroups.thumbnail = parsedThumbnailIfdTags;
|
|
305
309
|
}
|
|
306
310
|
|
|
307
|
-
const thumbnail = (
|
|
308
|
-
&&
|
|
309
|
-
&&
|
|
311
|
+
const thumbnail = (Constants.USE_JPEG || Constants.USE_WEBP)
|
|
312
|
+
&& Constants.USE_EXIF
|
|
313
|
+
&& Constants.USE_THUMBNAIL
|
|
310
314
|
&& deps.Thumbnail.get(exifDataView || dataView, parsedThumbnailIfdTags, tiffHeaderOffset);
|
|
311
315
|
if (thumbnail) {
|
|
312
316
|
tags.Thumbnail = thumbnail;
|
package/src/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type": "module"}
|