exifreader 4.12.0 → 4.13.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/dist/exif-reader.js +1 -1
- package/dist/exif-reader.js.map +1 -1
- package/package.json +2 -2
- package/src/dom-parser.js +9 -2
- package/src/xmp-tags.js +28 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "exifreader",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.13.0",
|
|
4
4
|
"description": "Library that parses Exif metadata in images.",
|
|
5
5
|
"author": "Mattias Wallander <mattias@wallander.eu>",
|
|
6
6
|
"repository": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
],
|
|
23
23
|
"types": "./exif-reader.d.ts",
|
|
24
24
|
"optionalDependencies": {
|
|
25
|
-
"@xmldom/xmldom": "^0.
|
|
25
|
+
"@xmldom/xmldom": "^0.8.8"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@babel/core": "^7.15.8",
|
package/src/dom-parser.js
CHANGED
|
@@ -8,10 +8,17 @@ export default {
|
|
|
8
8
|
|
|
9
9
|
function get() {
|
|
10
10
|
if (typeof DOMParser !== 'undefined') {
|
|
11
|
-
return DOMParser;
|
|
11
|
+
return new DOMParser();
|
|
12
12
|
}
|
|
13
13
|
try {
|
|
14
|
-
|
|
14
|
+
// eslint-disable-next-line no-undef
|
|
15
|
+
return new (__non_webpack_require__('@xmldom/xmldom').DOMParser)({
|
|
16
|
+
errorHandler: {
|
|
17
|
+
error: () => {
|
|
18
|
+
throw new Error('Faulty XML');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
});
|
|
15
22
|
} catch (error) {
|
|
16
23
|
return undefined;
|
|
17
24
|
}
|
package/src/xmp-tags.js
CHANGED
|
@@ -11,10 +11,31 @@ export default {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
function read(dataView, chunks) {
|
|
14
|
+
const tags = {};
|
|
15
|
+
|
|
14
16
|
if (typeof dataView === 'string') {
|
|
15
|
-
|
|
17
|
+
readTags(tags, dataView);
|
|
18
|
+
return tags;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const [standardXmp, extendedXmp] = extractCompleteChunks(dataView, chunks);
|
|
22
|
+
|
|
23
|
+
const hasStandardTags = readTags(tags, standardXmp);
|
|
24
|
+
|
|
25
|
+
if (extendedXmp) {
|
|
26
|
+
const hasExtendedTags = readTags(tags, extendedXmp);
|
|
27
|
+
|
|
28
|
+
if (!hasStandardTags && !hasExtendedTags) {
|
|
29
|
+
// Some writers are not spec-compliant in that they split an XMP
|
|
30
|
+
// metadata tree over both the standard XMP block and the extended
|
|
31
|
+
// XMP block. If we failed parsing both of the XMPs in the regular
|
|
32
|
+
// way, we try to combine them to see if that works better.
|
|
33
|
+
delete tags._raw;
|
|
34
|
+
readTags(tags, combineChunks(dataView, chunks));
|
|
35
|
+
}
|
|
16
36
|
}
|
|
17
|
-
|
|
37
|
+
|
|
38
|
+
return tags;
|
|
18
39
|
}
|
|
19
40
|
|
|
20
41
|
// The first chunk is always the regular XMP document. Then there is something
|
|
@@ -54,20 +75,20 @@ function readTags(tags, chunkDataView) {
|
|
|
54
75
|
tags._raw = (tags._raw || '') + raw;
|
|
55
76
|
const rdf = getRDF(doc);
|
|
56
77
|
|
|
57
|
-
|
|
78
|
+
objectAssign(tags, parseXMPObject(convertToObject(rdf, true)));
|
|
79
|
+
return true;
|
|
58
80
|
} catch (error) {
|
|
59
|
-
return
|
|
81
|
+
return false;
|
|
60
82
|
}
|
|
61
83
|
}
|
|
62
84
|
|
|
63
85
|
function getDocument(chunkDataView) {
|
|
64
|
-
const
|
|
65
|
-
if (!
|
|
86
|
+
const domParser = DOMParser.get();
|
|
87
|
+
if (!domParser) {
|
|
66
88
|
console.warn('Warning: DOMParser is not available. It is needed to be able to parse XMP tags.'); // eslint-disable-line no-console
|
|
67
89
|
throw new Error();
|
|
68
90
|
}
|
|
69
91
|
|
|
70
|
-
const domParser = new Parser();
|
|
71
92
|
const xmlString = typeof chunkDataView === 'string' ? chunkDataView : getStringFromDataView(chunkDataView, 0, chunkDataView.byteLength);
|
|
72
93
|
const doc = domParser.parseFromString(trimXmlSource(xmlString), 'application/xml');
|
|
73
94
|
|