exifreader 4.53.0 → 4.55.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 +404 -33
- package/bin/analyze.js +139 -9
- package/bin/build-pages.js +21 -35
- package/bin/cli.js +81 -13
- package/bin/generate-tag-modules.js +287 -0
- package/dist/exif-reader.js +1 -1
- package/dist/exif-reader.js.map +1 -1
- package/exif-reader.d.ts +213 -38
- package/package.json +71 -11
- package/src/base64-image.js +27 -0
- package/src/composable/brand.js +10 -0
- package/src/composable/composition-tag-filter.js +97 -0
- package/src/composable/composition.js +195 -0
- package/src/composable/core.d.ts +148 -0
- package/src/composable/core.js +526 -0
- package/src/composable/exif-block-reader.js +197 -0
- package/src/composable/formats/avif.js +19 -0
- package/src/composable/formats/gif.js +28 -0
- package/src/composable/formats/heic.js +19 -0
- package/src/composable/formats/iso-bmff-file-reader.js +14 -0
- package/src/composable/formats/jpeg.js +55 -0
- package/src/composable/formats/jxl.js +30 -0
- package/src/composable/formats/png.js +187 -0
- package/src/composable/formats/tiff.js +18 -0
- package/src/composable/formats/webp.js +28 -0
- package/src/composable/formats/xml.js +18 -0
- package/src/composable/formats.d.ts +17 -0
- package/src/composable/formats.js +17 -0
- package/src/composable/group-helpers.js +129 -0
- package/src/composable/groups/canon.js +26 -0
- package/src/composable/groups/composite.js +43 -0
- package/src/composable/groups/exif.js +48 -0
- package/src/composable/groups/gps.js +75 -0
- package/src/composable/groups/icc.js +52 -0
- package/src/composable/groups/iptc.js +86 -0
- package/src/composable/groups/maker-notes.js +21 -0
- package/src/composable/groups/mpf.js +25 -0
- package/src/composable/groups/pentax.js +34 -0
- package/src/composable/groups/photoshop.js +18 -0
- package/src/composable/groups/thumbnail.js +131 -0
- package/src/composable/groups/xmp.js +118 -0
- package/src/composable/groups.d.ts +20 -0
- package/src/composable/groups.js +105 -0
- package/src/composable/iptc-block-reader.js +44 -0
- package/src/composable/read-view.js +165 -0
- package/src/composable/tag-binding-name.js +17 -0
- package/src/composable/tags/exif.d.ts +295 -0
- package/src/composable/tags/exif.js +396 -0
- package/src/composable/tags/iptc.d.ts +84 -0
- package/src/composable/tags/iptc.js +109 -0
- package/src/composable/value-budget.js +24 -0
- package/src/composite.js +2 -2
- package/src/decompression.js +60 -0
- package/src/dom-parser.js +5 -6
- package/src/engine.js +332 -0
- package/src/errors.js +8 -2
- package/src/exif-reader.d.ts +8 -0
- package/src/exif-reader.js +118 -1121
- package/src/file-loaders.js +74 -1
- package/src/file-tags.js +9 -9
- 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 +25 -59
- package/src/iptc-tag-names-descriptions.js +334 -0
- package/src/iptc-tag-names.js +50 -306
- package/src/iptc-tags.js +41 -27
- package/src/jfif-tags.js +9 -9
- package/src/load-auto.js +2 -2
- package/src/loadview-pipeline.js +197 -498
- package/src/mpf-tags.js +10 -7
- package/src/node-require.js +15 -2
- package/src/png-text-tags.js +90 -327
- package/src/tag-filter-config.js +24 -15
- package/src/tag-filter.js +67 -3
- package/src/tag-names-0th-ifd-descriptions.js +232 -0
- package/src/tag-names-0th-ifd.js +49 -173
- package/src/tag-names-common.js +263 -211
- package/src/tag-names-exif-ifd-descriptions.js +249 -0
- package/src/tag-names-exif-ifd.js +55 -187
- package/src/tag-names-gps-ifd-descriptions.js +156 -0
- package/src/tag-names-gps-ifd.js +39 -146
- package/src/tag-names-utils.js +33 -10
- package/src/tags-helpers.js +14 -24
- package/src/tags.js +23 -11
- package/src/thumbnail.js +7 -5
- package/src/types.js +2 -0
- package/src/unsupported-format-error.js +21 -0
- package/src/utils.js +64 -119
- package/src/writer/exif-tag-table.js +321 -0
- package/src/xml.js +12 -15
- package/src/xmp-tag-names.js +42 -21
- package/src/xmp-tags.js +9 -10
- package/webpack.config.js +1 -1
package/src/image-header-jpeg.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, addBlock, pushRange} from './utils.js';
|
|
6
6
|
import ByteOrder from './byte-order.js';
|
|
7
7
|
import {
|
|
8
8
|
IFD_ENTRY_COUNT_LENGTH,
|
|
@@ -81,32 +81,38 @@ function isJpegFile(dataView) {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
|
-
* Walks the JPEG APP/SOF markers and reports the
|
|
84
|
+
* Walks the JPEG APP/SOF markers and reports the blocks ExifReader reads.
|
|
85
85
|
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* @
|
|
86
|
+
* Duplicates resolve inside the walk: the best-scored APP1 Exif segment wins,
|
|
87
|
+
* the last SOF0 (or, without one, the last SOF2), JFIF, IPTC and MPF segment
|
|
88
|
+
* wins, and the XMP and ICC segments form one block each with their chunks
|
|
89
|
+
* capped at MAX_XMP_CHUNKS and MAX_ICC_CHUNKS.
|
|
90
|
+
*
|
|
91
|
+
* @param {DataView} dataView The data view to find blocks in.
|
|
92
|
+
* @param {Array<Object>=} ranges Optional out-array. When provided, receives
|
|
93
|
+
* one `{block, start, end}` span per recognized segment, capped by
|
|
94
|
+
* neither chunk cap, and gets `truncated` set to true if the loop never
|
|
95
|
+
* saw the SOS marker.
|
|
96
|
+
* @returns {Array<Object>} The blocks, in the order their first segment was met.
|
|
92
97
|
*/
|
|
93
|
-
function findJpegOffsets(dataView,
|
|
98
|
+
function findJpegOffsets(dataView, ranges) {
|
|
99
|
+
const blocks = [];
|
|
94
100
|
let appMarkerPosition = JPEG_ID_SIZE;
|
|
95
101
|
let fieldLength;
|
|
96
102
|
let sof0DataOffset;
|
|
97
|
-
let
|
|
98
|
-
let
|
|
99
|
-
let
|
|
100
|
-
let
|
|
101
|
-
let
|
|
102
|
-
let
|
|
103
|
-
let
|
|
103
|
+
let fileBlock;
|
|
104
|
+
let jfifBlock;
|
|
105
|
+
let exifBlock;
|
|
106
|
+
let iptcBlock;
|
|
107
|
+
let xmpBlock;
|
|
108
|
+
let iccBlock;
|
|
109
|
+
let mpfBlock;
|
|
104
110
|
let exifSegmentCount = 0;
|
|
105
111
|
let bestExifSegment;
|
|
106
112
|
let sawSos = false;
|
|
107
113
|
|
|
108
114
|
while (appMarkerPosition + APP_ID_OFFSET + 5 <= dataView.byteLength) {
|
|
109
|
-
let
|
|
115
|
+
let block;
|
|
110
116
|
if (dataView.getUint16(appMarkerPosition) === SOS_MARKER) {
|
|
111
117
|
// Reaching SOS means the metadata region is closed.
|
|
112
118
|
sawSos = true;
|
|
@@ -114,15 +120,22 @@ function findJpegOffsets(dataView, metadataBlocks) {
|
|
|
114
120
|
if (isSOF0Marker(dataView, appMarkerPosition)) {
|
|
115
121
|
fieldLength = dataView.getUint16(appMarkerPosition + APP_MARKER_SIZE);
|
|
116
122
|
sof0DataOffset = appMarkerPosition + APP_MARKER_SIZE;
|
|
117
|
-
|
|
123
|
+
fileBlock = fileBlock || addBlock(blocks, {kind: 'file'});
|
|
124
|
+
fileBlock.dataOffset = sof0DataOffset;
|
|
125
|
+
block = fileBlock;
|
|
118
126
|
} else if (isSOF2Marker(dataView, appMarkerPosition)) {
|
|
119
127
|
fieldLength = dataView.getUint16(appMarkerPosition + APP_MARKER_SIZE);
|
|
120
|
-
|
|
121
|
-
|
|
128
|
+
fileBlock = fileBlock || addBlock(blocks, {kind: 'file'});
|
|
129
|
+
// A SOF0 segment wins over any SOF2 segment.
|
|
130
|
+
if (sof0DataOffset === undefined) {
|
|
131
|
+
fileBlock.dataOffset = appMarkerPosition + APP_MARKER_SIZE;
|
|
132
|
+
}
|
|
133
|
+
block = fileBlock;
|
|
122
134
|
} else if (isApp0JfifMarker(dataView, appMarkerPosition)) {
|
|
123
135
|
fieldLength = dataView.getUint16(appMarkerPosition + APP_MARKER_SIZE);
|
|
124
|
-
|
|
125
|
-
|
|
136
|
+
jfifBlock = jfifBlock || addBlock(blocks, {kind: 'jfif'});
|
|
137
|
+
jfifBlock.dataOffset = appMarkerPosition + JFIF_DATA_OFFSET;
|
|
138
|
+
block = jfifBlock;
|
|
126
139
|
} else if (isApp1ExifMarker(dataView, appMarkerPosition)) {
|
|
127
140
|
fieldLength = dataView.getUint16(appMarkerPosition + APP_MARKER_SIZE);
|
|
128
141
|
exifSegmentCount++;
|
|
@@ -163,48 +176,45 @@ function findJpegOffsets(dataView, metadataBlocks) {
|
|
|
163
176
|
}
|
|
164
177
|
}
|
|
165
178
|
|
|
166
|
-
|
|
167
|
-
|
|
179
|
+
exifBlock = exifBlock || addBlock(blocks, {kind: 'exif'});
|
|
180
|
+
exifBlock.tiffHeaderOffset = bestExifSegment.tiffHeaderOffset;
|
|
181
|
+
block = exifBlock;
|
|
168
182
|
} else if (isApp1XmpMarker(dataView, appMarkerPosition)) {
|
|
169
|
-
|
|
170
|
-
xmpChunks = [];
|
|
171
|
-
}
|
|
183
|
+
xmpBlock = xmpBlock || addBlock(blocks, {kind: 'xmp', chunks: []});
|
|
172
184
|
fieldLength = dataView.getUint16(appMarkerPosition + APP_MARKER_SIZE);
|
|
173
|
-
if (
|
|
174
|
-
|
|
185
|
+
if (xmpBlock.chunks.length < MAX_XMP_CHUNKS) {
|
|
186
|
+
xmpBlock.chunks.push(getXmpChunkDetails(appMarkerPosition, fieldLength));
|
|
175
187
|
}
|
|
176
|
-
|
|
188
|
+
block = xmpBlock;
|
|
177
189
|
} else if (isApp1ExtendedXmpMarker(dataView, appMarkerPosition)) {
|
|
178
|
-
|
|
179
|
-
xmpChunks = [];
|
|
180
|
-
}
|
|
190
|
+
xmpBlock = xmpBlock || addBlock(blocks, {kind: 'xmp', chunks: []});
|
|
181
191
|
fieldLength = dataView.getUint16(appMarkerPosition + APP_MARKER_SIZE);
|
|
182
|
-
if (
|
|
183
|
-
|
|
192
|
+
if (xmpBlock.chunks.length < MAX_XMP_CHUNKS) {
|
|
193
|
+
xmpBlock.chunks.push(getExtendedXmpChunkDetails(appMarkerPosition, fieldLength));
|
|
184
194
|
}
|
|
185
|
-
|
|
195
|
+
block = xmpBlock;
|
|
186
196
|
} else if (isApp13PhotoshopMarker(dataView, appMarkerPosition)) {
|
|
187
197
|
fieldLength = dataView.getUint16(appMarkerPosition + APP_MARKER_SIZE);
|
|
188
|
-
|
|
189
|
-
|
|
198
|
+
iptcBlock = iptcBlock || addBlock(blocks, {kind: 'iptc'});
|
|
199
|
+
iptcBlock.dataOffset = appMarkerPosition + IPTC_DATA_OFFSET;
|
|
200
|
+
block = iptcBlock;
|
|
190
201
|
} else if (isApp2ICCMarker(dataView, appMarkerPosition)) {
|
|
191
202
|
fieldLength = dataView.getUint16(appMarkerPosition + APP_MARKER_SIZE);
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
if (iccChunks.length < MAX_ICC_CHUNKS) {
|
|
203
|
+
iccBlock = iccBlock || addBlock(blocks, {kind: 'icc', chunks: []});
|
|
204
|
+
if (iccBlock.chunks.length < MAX_ICC_CHUNKS) {
|
|
196
205
|
const iccDataOffset = appMarkerPosition + APP2_ICC_DATA_OFFSET;
|
|
197
206
|
const iccDataLength = fieldLength - (APP2_ICC_DATA_OFFSET - APP_MARKER_SIZE);
|
|
198
207
|
|
|
199
208
|
const iccChunkNumber = dataView.getUint8(appMarkerPosition + ICC_CHUNK_NUMBER_OFFSET);
|
|
200
209
|
const iccChunksTotal = dataView.getUint8(appMarkerPosition + ICC_TOTAL_CHUNKS_OFFSET);
|
|
201
|
-
|
|
210
|
+
iccBlock.chunks.push({offset: iccDataOffset, length: iccDataLength, chunkNumber: iccChunkNumber, chunksTotal: iccChunksTotal});
|
|
202
211
|
}
|
|
203
|
-
|
|
212
|
+
block = iccBlock;
|
|
204
213
|
} else if (isApp2MPFMarker(dataView, appMarkerPosition)) {
|
|
205
214
|
fieldLength = dataView.getUint16(appMarkerPosition + APP_MARKER_SIZE);
|
|
206
|
-
|
|
207
|
-
|
|
215
|
+
mpfBlock = mpfBlock || addBlock(blocks, {kind: 'mpf'});
|
|
216
|
+
mpfBlock.dataOffset = appMarkerPosition + MPF_DATA_OFFSET;
|
|
217
|
+
block = mpfBlock;
|
|
208
218
|
} else if (isAppMarker(dataView, appMarkerPosition)) {
|
|
209
219
|
fieldLength = dataView.getUint16(appMarkerPosition + APP_MARKER_SIZE);
|
|
210
220
|
} else if (isFillByte(dataView, appMarkerPosition)) {
|
|
@@ -213,7 +223,7 @@ function findJpegOffsets(dataView, metadataBlocks) {
|
|
|
213
223
|
} else {
|
|
214
224
|
break;
|
|
215
225
|
}
|
|
216
|
-
|
|
226
|
+
pushRange(ranges, block, appMarkerPosition, appMarkerPosition + APP_MARKER_SIZE + fieldLength);
|
|
217
227
|
appMarkerPosition += APP_MARKER_SIZE + fieldLength;
|
|
218
228
|
}
|
|
219
229
|
|
|
@@ -221,7 +231,7 @@ function findJpegOffsets(dataView, metadataBlocks) {
|
|
|
221
231
|
warnAboutMultipleExifSegments(exifSegmentCount);
|
|
222
232
|
}
|
|
223
233
|
|
|
224
|
-
if (
|
|
234
|
+
if (ranges) {
|
|
225
235
|
// The while-condition requires +5 bytes to enter, so the SOS marker
|
|
226
236
|
// can sit right at the boundary where the loop exits without
|
|
227
237
|
// entering. Catch that here.
|
|
@@ -232,19 +242,10 @@ function findJpegOffsets(dataView, metadataBlocks) {
|
|
|
232
242
|
}
|
|
233
243
|
// The pipeline combines this with the per-block end <= byteLength
|
|
234
244
|
// check to compute the overall `complete` flag.
|
|
235
|
-
|
|
245
|
+
ranges.truncated = !sawSos;
|
|
236
246
|
}
|
|
237
247
|
|
|
238
|
-
return
|
|
239
|
-
hasAppMarkers: appMarkerPosition > JPEG_ID_SIZE,
|
|
240
|
-
fileDataOffset: sof0DataOffset || sof2DataOffset,
|
|
241
|
-
jfifDataOffset,
|
|
242
|
-
tiffHeaderOffset,
|
|
243
|
-
iptcDataOffset,
|
|
244
|
-
xmpChunks,
|
|
245
|
-
iccChunks,
|
|
246
|
-
mpfDataOffset
|
|
247
|
-
};
|
|
248
|
+
return blocks;
|
|
248
249
|
}
|
|
249
250
|
|
|
250
251
|
function isSOF0Marker(dataView, appMarkerPosition) {
|
package/src/image-header-jxl.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
4
|
|
|
5
5
|
import {getBoxLength, getTiffHeaderOffset, BOX_TYPE_OFFSET, BOX_MIN_LENGTH} from './image-header-iso-bmff.js';
|
|
6
|
-
import {
|
|
6
|
+
import {pushRange} from './utils.js';
|
|
7
7
|
|
|
8
8
|
export default {
|
|
9
9
|
isJxlFile,
|
|
@@ -66,34 +66,36 @@ function isJxlCodestream(dataView) {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
|
-
* Walks the JPEG XL box list and reports the
|
|
69
|
+
* Walks the JPEG XL box list and reports the blocks ExifReader reads.
|
|
70
70
|
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
71
|
+
* An Exif box that holds its TIFF header offset wins over any brob(Exif) box,
|
|
72
|
+
* otherwise the first brob(Exif) is reported; the same goes for the xml box
|
|
73
|
+
* and brob(xml). The last Exif or xml box wins among its own kind. The
|
|
74
|
+
* `jxlFile` block points at the codestream: the first jxlc box, or the first
|
|
75
|
+
* jxlp box with sequence number 0. A bare codestream is only a `jxlFile`
|
|
76
|
+
* block at offset 0.
|
|
77
|
+
*
|
|
78
|
+
* @param {DataView} dataView The data view to find blocks in.
|
|
79
|
+
* @param {Array<Object>=} ranges Optional out-array. When provided, receives
|
|
80
|
+
* one `{block, start, end}` span per recognized box (Exif, xml, brob with
|
|
81
|
+
* Exif or xml original type), a brob box's span linked to its own block
|
|
82
|
+
* even when another box wins. The codestream box (`jxlc`/`jxlp`) gets no
|
|
83
|
+
* span because it wraps the encoded image, not metadata.
|
|
84
|
+
* @returns {Array<Object>} The blocks: exif, xmp and jxlFile, each when found.
|
|
77
85
|
*/
|
|
78
|
-
function findJxlOffsets(dataView,
|
|
86
|
+
function findJxlOffsets(dataView, ranges) {
|
|
87
|
+
const blocks = [];
|
|
79
88
|
let offset = 0;
|
|
80
|
-
let
|
|
81
|
-
let
|
|
82
|
-
let
|
|
83
|
-
let
|
|
84
|
-
let
|
|
89
|
+
let exifBoxBlock;
|
|
90
|
+
let brobExifBlock;
|
|
91
|
+
let xmlBoxBlock;
|
|
92
|
+
let brobXmpBlock;
|
|
93
|
+
let jxlFileBlock;
|
|
85
94
|
|
|
86
95
|
if (isJxlCodestream(dataView)) {
|
|
87
96
|
// A bare codestream has no box structure, so the box walk below
|
|
88
97
|
// would only ever misinterpret codestream bytes as box headers.
|
|
89
|
-
return {
|
|
90
|
-
hasAppMarkers: true,
|
|
91
|
-
tiffHeaderOffset: undefined,
|
|
92
|
-
xmpChunks: undefined,
|
|
93
|
-
brobExifChunk: undefined,
|
|
94
|
-
brobXmpChunk: undefined,
|
|
95
|
-
jxlCodestreamOffset: 0,
|
|
96
|
-
};
|
|
98
|
+
return [{kind: 'jxlFile', codestreamOffset: 0}];
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
while (offset + BOX_MIN_LENGTH <= dataView.byteLength) {
|
|
@@ -104,34 +106,40 @@ function findJxlOffsets(dataView, metadataBlocks) {
|
|
|
104
106
|
const contentEnd = Math.min(offset + length, dataView.byteLength);
|
|
105
107
|
|
|
106
108
|
const boxType = dataView.getUint32(offset + BOX_TYPE_OFFSET);
|
|
107
|
-
let
|
|
109
|
+
let block;
|
|
108
110
|
|
|
109
111
|
if (boxType === TYPE_EXIF) {
|
|
110
112
|
if (contentOffset + EXIF_TIFF_HEADER_OFFSET_SIZE <= contentEnd) {
|
|
111
|
-
|
|
113
|
+
exifBoxBlock = exifBoxBlock || {kind: 'exif'};
|
|
114
|
+
exifBoxBlock.tiffHeaderOffset = getTiffHeaderOffset(dataView, contentOffset);
|
|
115
|
+
block = exifBoxBlock;
|
|
116
|
+
} else {
|
|
117
|
+
// Too short to hold its TIFF header offset: listed, never read,
|
|
118
|
+
// and no bar to a brob(Exif) box.
|
|
119
|
+
block = {kind: 'exif'};
|
|
112
120
|
}
|
|
113
|
-
blockType = 'exif';
|
|
114
121
|
}
|
|
115
122
|
|
|
116
123
|
if (boxType === TYPE_XML) {
|
|
117
|
-
|
|
124
|
+
xmlBoxBlock = xmlBoxBlock || {kind: 'xmp'};
|
|
125
|
+
xmlBoxBlock.chunks = [{
|
|
118
126
|
dataOffset: contentOffset,
|
|
119
127
|
length: length - (contentOffset - offset)
|
|
120
128
|
}];
|
|
121
|
-
|
|
129
|
+
block = xmlBoxBlock;
|
|
122
130
|
}
|
|
123
131
|
|
|
124
|
-
if (boxType === TYPE_JXLC &&
|
|
125
|
-
|
|
126
|
-
// No
|
|
132
|
+
if (boxType === TYPE_JXLC && jxlFileBlock === undefined) {
|
|
133
|
+
jxlFileBlock = {kind: 'jxlFile', codestreamOffset: contentOffset};
|
|
134
|
+
// No span listed: the codestream box wraps the encoded image,
|
|
127
135
|
// marking it would inflate metadataRange.end past pixel data.
|
|
128
136
|
}
|
|
129
137
|
|
|
130
|
-
if (boxType === TYPE_JXLP &&
|
|
138
|
+
if (boxType === TYPE_JXLP && jxlFileBlock === undefined
|
|
131
139
|
&& contentOffset + JXLP_SEQUENCE_NUMBER_SIZE <= contentEnd) {
|
|
132
140
|
const sequenceNumber = dataView.getUint32(contentOffset) & 0x7FFFFFFF;
|
|
133
141
|
if (sequenceNumber === 0) {
|
|
134
|
-
|
|
142
|
+
jxlFileBlock = {kind: 'jxlFile', codestreamOffset: contentOffset + JXLP_SEQUENCE_NUMBER_SIZE};
|
|
135
143
|
// Same reason as TYPE_JXLC above.
|
|
136
144
|
}
|
|
137
145
|
}
|
|
@@ -141,47 +149,33 @@ function findJxlOffsets(dataView, metadataBlocks) {
|
|
|
141
149
|
const compressedDataOffset = contentOffset + BROB_ORIGINAL_TYPE_SIZE;
|
|
142
150
|
const compressedDataLength = length - (compressedDataOffset - offset);
|
|
143
151
|
|
|
144
|
-
//
|
|
145
|
-
//
|
|
146
|
-
//
|
|
147
|
-
// variables stay guarded to avoid double-parsing.
|
|
152
|
+
// Every brob box gets its own block for its span, but only the
|
|
153
|
+
// first of a kind can be the one read, and only when no plain box
|
|
154
|
+
// of that kind holds the data.
|
|
148
155
|
if (originalType === TYPE_EXIF) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
brobExifChunk = {
|
|
152
|
-
dataOffset: compressedDataOffset,
|
|
153
|
-
length: compressedDataLength
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
+
block = {kind: 'exif', compression: 'brotli', dataOffset: compressedDataOffset, length: compressedDataLength};
|
|
157
|
+
brobExifBlock = brobExifBlock || block;
|
|
156
158
|
}
|
|
157
159
|
if (originalType === TYPE_XML) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
brobXmpChunk = {
|
|
161
|
-
dataOffset: compressedDataOffset,
|
|
162
|
-
length: compressedDataLength
|
|
163
|
-
};
|
|
164
|
-
}
|
|
160
|
+
block = {kind: 'xmp', compression: 'brotli', dataOffset: compressedDataOffset, length: compressedDataLength};
|
|
161
|
+
brobXmpBlock = brobXmpBlock || block;
|
|
165
162
|
}
|
|
166
163
|
}
|
|
167
164
|
|
|
168
|
-
|
|
165
|
+
pushRange(ranges, block, offset, offset + length);
|
|
169
166
|
|
|
170
167
|
offset += length;
|
|
171
168
|
}
|
|
172
169
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
brobXmpChunk,
|
|
185
|
-
jxlCodestreamOffset
|
|
186
|
-
};
|
|
170
|
+
pushDefinedBlock(blocks, exifBoxBlock || brobExifBlock);
|
|
171
|
+
pushDefinedBlock(blocks, xmlBoxBlock || brobXmpBlock);
|
|
172
|
+
pushDefinedBlock(blocks, jxlFileBlock);
|
|
173
|
+
|
|
174
|
+
return blocks;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function pushDefinedBlock(blocks, block) {
|
|
178
|
+
if (block !== undefined) {
|
|
179
|
+
blocks.push(block);
|
|
180
|
+
}
|
|
187
181
|
}
|