exifreader 4.53.0 → 4.54.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 +6 -6
- package/dist/exif-reader.js +1 -1
- package/dist/exif-reader.js.map +1 -1
- package/package.json +1 -1
- package/src/base64-image.js +27 -0
- package/src/dom-parser.js +5 -6
- package/src/engine.js +388 -0
- package/src/exif-reader.js +540 -892
- package/src/image-header-avif.js +7 -8
- package/src/image-header-gif.js +9 -10
- package/src/image-header-heic.js +7 -8
- package/src/image-header-iso-bmff.js +71 -92
- package/src/image-header-jpeg.js +60 -59
- package/src/image-header-jxl.js +59 -65
- package/src/image-header-png.js +199 -76
- package/src/image-header-tiff.js +7 -4
- package/src/image-header-webp.js +29 -35
- package/src/image-header.js +22 -22
- package/src/loadview-pipeline.js +285 -446
- package/src/mpf-tags.js +10 -7
- package/src/png-text-tags.js +88 -327
- package/src/tag-filter.js +52 -0
- package/src/tag-names-0th-ifd.js +2 -2
- package/src/tag-names-utils.js +5 -7
- package/src/tags-helpers.js +8 -22
- package/src/tags.js +23 -11
- package/src/thumbnail.js +7 -5
- package/src/utils.js +42 -34
- package/src/writer/exif-tag-table.js +321 -0
- package/src/xml.js +12 -15
- package/src/xmp-tags.js +9 -10
package/src/xml.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
|
-
import {getStringFromDataView,
|
|
5
|
+
import {getStringFromDataView, pushRange} from './utils.js';
|
|
6
6
|
|
|
7
7
|
export default {
|
|
8
8
|
isXMLFile,
|
|
@@ -30,24 +30,21 @@ function isXMLFile(dataView) {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
33
|
+
* Reports a standalone XMP file as one xmp block covering the whole buffer.
|
|
34
34
|
*
|
|
35
|
-
* @param {DataView} dataView The data view to find
|
|
36
|
-
* @param {Array<Object>=}
|
|
37
|
-
*
|
|
35
|
+
* @param {DataView} dataView The data view to find blocks in.
|
|
36
|
+
* @param {Array<Object>=} ranges Optional out-array. When provided, receives
|
|
37
|
+
* one span covering the whole buffer, linked to the xmp block, and gets a
|
|
38
38
|
* `truncated` property set to true if no XMP closing marker is found.
|
|
39
|
-
* @returns {
|
|
39
|
+
* @returns {Array<Object>} One xmp block with one chunk.
|
|
40
40
|
*/
|
|
41
|
-
function findOffsets(dataView,
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
metadataBlocks.truncated = !hasXmpClosingMarker(dataView);
|
|
41
|
+
function findOffsets(dataView, ranges) {
|
|
42
|
+
const block = {kind: 'xmp', chunks: [{dataOffset: XML_MARKER_OFFSET, length: dataView.byteLength}]};
|
|
43
|
+
pushRange(ranges, block, 0, dataView.byteLength);
|
|
44
|
+
if (ranges) {
|
|
45
|
+
ranges.truncated = !hasXmpClosingMarker(dataView);
|
|
47
46
|
}
|
|
48
|
-
return
|
|
49
|
-
xmpChunks,
|
|
50
|
-
};
|
|
47
|
+
return [block];
|
|
51
48
|
}
|
|
52
49
|
|
|
53
50
|
function hasXmpClosingMarker(dataView) {
|
package/src/xmp-tags.js
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
import {decodeUtf8ByteString, getByteString, getTagKey, objectAssign, setProperty, tryDecodeUtf8ByteString} from './utils.js';
|
|
6
6
|
import XmpTagNames from './xmp-tag-names.js';
|
|
7
|
-
import DOMParser from './dom-parser.js';
|
|
8
7
|
import TextDecoder from './text-decoder.js';
|
|
9
8
|
import {isMissingNamespaceError, addMissingNamespaces} from './xmp-namespaces.js';
|
|
10
9
|
import {exceedsMarkupBounds} from './xmp-element-depth.js';
|
|
@@ -48,20 +47,20 @@ class ParseError extends Error {
|
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
function read(dataView, chunks, domParser) {
|
|
50
|
+
function read(dataView, chunks, domParser, getDomParser) {
|
|
52
51
|
const tags = {};
|
|
53
52
|
|
|
54
53
|
if (typeof dataView === 'string') {
|
|
55
|
-
readTags(tags, dataView, domParser);
|
|
54
|
+
readTags(tags, dataView, domParser, getDomParser);
|
|
56
55
|
return tags;
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
const [standardXmp, extendedXmp] = extractCompleteChunks(dataView, chunks);
|
|
60
59
|
|
|
61
|
-
const hasStandardTags = readTags(tags, standardXmp, domParser);
|
|
60
|
+
const hasStandardTags = readTags(tags, standardXmp, domParser, getDomParser);
|
|
62
61
|
|
|
63
62
|
if (extendedXmp) {
|
|
64
|
-
const hasExtendedTags = readTags(tags, extendedXmp, domParser);
|
|
63
|
+
const hasExtendedTags = readTags(tags, extendedXmp, domParser, getDomParser);
|
|
65
64
|
|
|
66
65
|
if (!hasStandardTags && !hasExtendedTags) {
|
|
67
66
|
// Some writers are not spec-compliant in that they split an XMP
|
|
@@ -69,7 +68,7 @@ function read(dataView, chunks, domParser) {
|
|
|
69
68
|
// XMP block. If we failed parsing both of the XMPs in the regular
|
|
70
69
|
// way, we try to combine them to see if that works better.
|
|
71
70
|
delete tags._raw;
|
|
72
|
-
readTags(tags, combineChunks(dataView, chunks), domParser);
|
|
71
|
+
readTags(tags, combineChunks(dataView, chunks), domParser, getDomParser);
|
|
73
72
|
}
|
|
74
73
|
}
|
|
75
74
|
|
|
@@ -118,9 +117,9 @@ function getBoundedChunkBytes(dataView, chunk) {
|
|
|
118
117
|
return new Uint8Array(dataView.buffer, byteOffset + start, end - start);
|
|
119
118
|
}
|
|
120
119
|
|
|
121
|
-
function readTags(tags, chunkDataView, domParser) {
|
|
120
|
+
function readTags(tags, chunkDataView, domParser, getDomParser) {
|
|
122
121
|
try {
|
|
123
|
-
const {doc, raw, decodeValue} = getDocument(chunkDataView, domParser);
|
|
122
|
+
const {doc, raw, decodeValue} = getDocument(chunkDataView, domParser, getDomParser);
|
|
124
123
|
tags._raw = (tags._raw || '') + raw;
|
|
125
124
|
const rdf = getRDF(doc);
|
|
126
125
|
|
|
@@ -138,8 +137,8 @@ function readTags(tags, chunkDataView, domParser) {
|
|
|
138
137
|
}
|
|
139
138
|
}
|
|
140
139
|
|
|
141
|
-
function getDocument(chunkDataView, _domParser) {
|
|
142
|
-
const {parser: domParser, warning} =
|
|
140
|
+
function getDocument(chunkDataView, _domParser, getDomParser) {
|
|
141
|
+
const {parser: domParser, warning} = getDomParser(_domParser);
|
|
143
142
|
if (!domParser) {
|
|
144
143
|
console.warn(warning); // eslint-disable-line no-console
|
|
145
144
|
throw new Error();
|