exifreader 4.25.0 → 4.26.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 +2 -4
- package/dist/exif-reader.js +1 -1
- package/dist/exif-reader.js.map +1 -1
- package/package.json +4 -4
- package/src/canon-tags.js +2 -0
- package/src/iptc-tags.js +15 -8
- package/src/tag-names-0th-ifd.js +29 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "exifreader",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.26.1",
|
|
4
4
|
"description": "Library that parses Exif metadata in images.",
|
|
5
5
|
"author": "Mattias Wallander <mattias@wallander.eu>",
|
|
6
6
|
"repository": {
|
|
@@ -33,18 +33,18 @@
|
|
|
33
33
|
"babel-plugin-rewire": "^1.2.0",
|
|
34
34
|
"chai": "^4.3.10",
|
|
35
35
|
"cross-env": "^7.0.3",
|
|
36
|
-
"cypress": "^
|
|
36
|
+
"cypress": "^14.0.0",
|
|
37
37
|
"eslint": "^8.52.0",
|
|
38
38
|
"eslint-plugin-cypress": "^3.0.2",
|
|
39
39
|
"husky": "^9.0.11",
|
|
40
|
-
"mocha": "^
|
|
40
|
+
"mocha": "^11.0.1",
|
|
41
41
|
"npm-run-all": "^4.1.5",
|
|
42
42
|
"nyc": "^17.0.0",
|
|
43
43
|
"rimraf": "^5.0.5",
|
|
44
44
|
"string-replace-loader": "^3.1.0",
|
|
45
45
|
"terser-webpack-plugin": "^5.3.10",
|
|
46
46
|
"typescript": "^5.6.2",
|
|
47
|
-
"webpack": "
|
|
47
|
+
"webpack": "5.97.1",
|
|
48
48
|
"webpack-cli": "^5.1.4",
|
|
49
49
|
"webpack-dev-server": "^5.0.4"
|
|
50
50
|
},
|
package/src/canon-tags.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
4
|
|
|
5
5
|
// Reverse-engineered docs:
|
|
6
|
+
// https://exiftool.org/makernote_types.html
|
|
7
|
+
// https://exiv2.org/makernote.html
|
|
6
8
|
// https://exiv2.org/tags-canon.html
|
|
7
9
|
// https://gist.github.com/redaktor/bae0ef2377ab70bc5276
|
|
8
10
|
// https://www.ozhiker.com/electronics/pjmt/jpeg_info/canon_mn.html
|
package/src/iptc-tags.js
CHANGED
|
@@ -7,8 +7,12 @@ import TagDecoder from './tag-decoder.js';
|
|
|
7
7
|
|
|
8
8
|
const BYTES_8BIM = 0x3842494d;
|
|
9
9
|
const BYTES_8BIM_SIZE = 4;
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const RESOURCE_ID_SIZE = 2;
|
|
11
|
+
const RESOURCE_NAME_SIZE_SIZE = 1;
|
|
12
|
+
const RESOURCE_NAME_MIN_SIZE = 2;
|
|
13
|
+
const RESOURCE_SIZE_SIZE = 4;
|
|
14
|
+
const RESOURCE_BLOCK_MIN_HEADER_SIZE = BYTES_8BIM_SIZE + RESOURCE_ID_SIZE + RESOURCE_NAME_MIN_SIZE + RESOURCE_SIZE_SIZE;
|
|
15
|
+
const NAA_RESOURCE_BLOCK_TYPE = 0x0404; // Sometimes called resource ID.
|
|
12
16
|
const TAG_HEADER_SIZE = 5;
|
|
13
17
|
|
|
14
18
|
export default {
|
|
@@ -28,26 +32,29 @@ function read(dataView, dataOffset, includeUnknown) {
|
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
function getNaaResourceBlock(dataView, dataOffset) {
|
|
31
|
-
while (dataOffset +
|
|
35
|
+
while (dataOffset + RESOURCE_BLOCK_MIN_HEADER_SIZE <= dataView.byteLength) {
|
|
32
36
|
const resourceBlock = getResourceBlock(dataView, dataOffset);
|
|
33
37
|
if (isNaaResourceBlock(resourceBlock)) {
|
|
34
|
-
return {naaBlock: resourceBlock, dataOffset: dataOffset +
|
|
38
|
+
return {naaBlock: resourceBlock, dataOffset: dataOffset + resourceBlock.headerSize};
|
|
35
39
|
}
|
|
36
|
-
dataOffset +=
|
|
40
|
+
dataOffset += resourceBlock.headerSize + resourceBlock.size + getBlockPadding(resourceBlock);
|
|
37
41
|
}
|
|
38
42
|
throw new Error('No IPTC NAA resource block.');
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
function getResourceBlock(dataView, dataOffset) {
|
|
42
|
-
const RESOURCE_BLOCK_SIZE_OFFSET = 10;
|
|
43
|
-
|
|
44
46
|
if (dataView.getUint32(dataOffset, false) !== BYTES_8BIM) {
|
|
45
47
|
throw new Error('Not an IPTC resource block.');
|
|
46
48
|
}
|
|
47
49
|
|
|
50
|
+
// We currently do not use the resource name for anything, we just need to know the size.
|
|
51
|
+
const resourceNameSize = dataView.getUint8(dataOffset + BYTES_8BIM_SIZE + RESOURCE_ID_SIZE);
|
|
52
|
+
const resourceNameTotalSize = (resourceNameSize % 2 === 0 ? resourceNameSize + 1 : resourceNameSize) + RESOURCE_NAME_SIZE_SIZE;
|
|
53
|
+
|
|
48
54
|
return {
|
|
55
|
+
headerSize: BYTES_8BIM_SIZE + RESOURCE_ID_SIZE + resourceNameTotalSize + RESOURCE_SIZE_SIZE,
|
|
49
56
|
type: dataView.getUint16(dataOffset + BYTES_8BIM_SIZE),
|
|
50
|
-
size: dataView.
|
|
57
|
+
size: dataView.getUint32(dataOffset + BYTES_8BIM_SIZE + RESOURCE_ID_SIZE + resourceNameTotalSize),
|
|
51
58
|
};
|
|
52
59
|
}
|
|
53
60
|
|
package/src/tag-names-0th-ifd.js
CHANGED
|
@@ -230,11 +230,26 @@ export default {
|
|
|
230
230
|
0x87b0: 'GeoTiffDoubleParams',
|
|
231
231
|
0x87b1: 'GeoTiffAsciiParams',
|
|
232
232
|
0x8825: 'GPS Info IFD Pointer',
|
|
233
|
-
0x9c9b:
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
233
|
+
0x9c9b: {
|
|
234
|
+
name: 'XPTitle',
|
|
235
|
+
description: decodeXPValue,
|
|
236
|
+
},
|
|
237
|
+
0x9c9c: {
|
|
238
|
+
name: 'XPComment',
|
|
239
|
+
description: decodeXPValue
|
|
240
|
+
},
|
|
241
|
+
0x9c9d: {
|
|
242
|
+
name: 'XPAuthor',
|
|
243
|
+
description: decodeXPValue,
|
|
244
|
+
},
|
|
245
|
+
0x9c9e: {
|
|
246
|
+
name: 'XPKeywords',
|
|
247
|
+
description: decodeXPValue,
|
|
248
|
+
},
|
|
249
|
+
0x9c9f: {
|
|
250
|
+
name: 'XPSubject',
|
|
251
|
+
description: decodeXPValue,
|
|
252
|
+
},
|
|
238
253
|
0xa480: 'GDALMetadata',
|
|
239
254
|
0xa481: 'GDALNoData',
|
|
240
255
|
0xc4a5: 'PrintIM',
|
|
@@ -355,3 +370,12 @@ export default {
|
|
|
355
370
|
0xc7a7: 'NewRawImageDigest',
|
|
356
371
|
0xc7a8: 'RawToPreviewGain'
|
|
357
372
|
};
|
|
373
|
+
|
|
374
|
+
function decodeXPValue(value) {
|
|
375
|
+
// The XP tags are encoded as UCS-2 which uses two bytes per character but
|
|
376
|
+
// it's close to UTF-16 so we can use that to decode them.
|
|
377
|
+
// https://www.loc.gov/preservation/digital/formats/content/tiff_tags.shtml
|
|
378
|
+
const decodedValue = new TextDecoder('utf-16').decode(new Uint8Array(value));
|
|
379
|
+
// Some softwares pad the string with null characters so we remove them.
|
|
380
|
+
return decodedValue.replace(/\u0000+$/, ''); // eslint-disable-line no-control-regex
|
|
381
|
+
}
|