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/exif-reader.js
CHANGED
|
@@ -7,55 +7,36 @@
|
|
|
7
7
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import {objectAssign,
|
|
10
|
+
import {objectAssign, getDataViewFromBytes, assertPromiseSupport} from './utils.js';
|
|
11
11
|
import {isFilePathOrURL, isBrowserFileObject, loadFile, loadFileObject} from './file-loaders.js';
|
|
12
12
|
import {makeLoadAuto, validateAutoOptions} from './load-auto.js';
|
|
13
13
|
import Constants from './constants.js';
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
import {getTiffHeaderOffset} from './image-header-iso-bmff.js';
|
|
17
|
-
import ImageHeader from './image-header.js';
|
|
18
|
-
import Tags from './tags.js';
|
|
19
|
-
import TagNames0thIfd from './tag-names-0th-ifd.js';
|
|
20
|
-
import TagNamesExifIfd from './tag-names-exif-ifd.js';
|
|
21
|
-
import TagNamesGpsIfd from './tag-names-gps-ifd.js';
|
|
22
|
-
import TagNamesInteroperabilityIfd from './tag-names-interoperability-ifd.js';
|
|
23
|
-
import {IFD_TYPE_0TH, IFD_TYPE_1ST, IFD_TYPE_EXIF, IFD_TYPE_GPS, IFD_TYPE_INTEROPERABILITY} from './ifd-types.js';
|
|
24
|
-
import {getValueBudget, addDecompressedValueAllowance, takeEmbeddedExifThumbnail} from './tags-helpers.js';
|
|
25
|
-
import MpfTags from './mpf-tags.js';
|
|
26
|
-
import FileTags from './file-tags.js';
|
|
27
|
-
import JxlFileTags from './jxl-file-tags.js';
|
|
28
|
-
import IsoBmffFileTags from './iso-bmff-file-tags.js';
|
|
29
|
-
import JfifTags from './jfif-tags.js';
|
|
30
|
-
import IptcTags from './iptc-tags.js';
|
|
31
|
-
import XmpTags from './xmp-tags.js';
|
|
32
|
-
import PhotoshopTags from './photoshop-tags.js';
|
|
33
|
-
import IccTags from './icc-tags.js';
|
|
34
|
-
import CanonTags from './canon-tags.js';
|
|
35
|
-
import PentaxTags from './pentax-tags.js';
|
|
36
|
-
import PngFileTags from './png-file-tags.js';
|
|
37
|
-
import PngTextTags from './png-text-tags.js';
|
|
38
|
-
import PngTags from './png-tags.js';
|
|
39
|
-
import Vp8xTags from './vp8x-tags.js';
|
|
40
|
-
import GifFileTags from './gif-file-tags.js';
|
|
41
|
-
import Thumbnail from './thumbnail.js';
|
|
42
|
-
import Composite from './composite.js';
|
|
43
|
-
import {createTagFilter} from './tag-filter.js';
|
|
44
|
-
import {buildTagsFromMergeSteps, EXIF_CARRIED_GROUP_ORDER} from './loadview-pipeline.js';
|
|
14
|
+
import {getBase64Image} from './base64-image.js';
|
|
15
|
+
import DOMParser from './dom-parser.js';
|
|
45
16
|
import exifErrors from './errors.js';
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
17
|
+
import Composition, {createIsHiddenInSyncMode} from './composable/composition.js';
|
|
18
|
+
import {readView} from './composable/read-view.js';
|
|
19
|
+
import {createTagFilter} from './tag-filter.js';
|
|
20
|
+
import {tiff} from './composable/formats/tiff.js';
|
|
21
|
+
import {jpegHeader, file, jfif} from './composable/formats/jpeg.js';
|
|
22
|
+
import {pngHeader, pngFile, pngText, pngChunk} from './composable/formats/png.js';
|
|
23
|
+
import {heic} from './composable/formats/heic.js';
|
|
24
|
+
import {avif} from './composable/formats/avif.js';
|
|
25
|
+
import {jxl} from './composable/formats/jxl.js';
|
|
26
|
+
import {webp} from './composable/formats/webp.js';
|
|
27
|
+
import {gif} from './composable/formats/gif.js';
|
|
28
|
+
import {xml} from './composable/formats/xml.js';
|
|
29
|
+
import {exif} from './composable/groups/exif.js';
|
|
30
|
+
import {iptc} from './composable/groups/iptc.js';
|
|
31
|
+
import {xmp} from './composable/groups/xmp.js';
|
|
32
|
+
import {icc} from './composable/groups/icc.js';
|
|
33
|
+
import {photoshop} from './composable/groups/photoshop.js';
|
|
34
|
+
import {mpf} from './composable/groups/mpf.js';
|
|
35
|
+
import {makerNotes} from './composable/groups/maker-notes.js';
|
|
36
|
+
import {gps} from './composable/groups/gps.js';
|
|
37
|
+
import {composite} from './composable/groups/composite.js';
|
|
38
|
+
import {thumbnail, getSelectedThumbnail} from './composable/groups/thumbnail.js';
|
|
39
|
+
import {removeThumbnailTag} from './loadview-pipeline.js';
|
|
59
40
|
|
|
60
41
|
export default {
|
|
61
42
|
load,
|
|
@@ -63,6 +44,11 @@ export default {
|
|
|
63
44
|
errors: exifErrors,
|
|
64
45
|
};
|
|
65
46
|
|
|
47
|
+
// Composing costs more than a small load, so the composition is kept until the
|
|
48
|
+
// tables change; they only do when the unit tests swap the Constants.
|
|
49
|
+
let defaultComposition;
|
|
50
|
+
let defaultCompositionEntries;
|
|
51
|
+
|
|
66
52
|
export const errors = exifErrors;
|
|
67
53
|
|
|
68
54
|
export function load(data, options = {}) {
|
|
@@ -84,1101 +70,112 @@ function loadFromData(data, options) {
|
|
|
84
70
|
return loadView(getDataViewFromBytes(data), options);
|
|
85
71
|
}
|
|
86
72
|
|
|
87
|
-
export function loadView(
|
|
88
|
-
dataView,
|
|
89
|
-
{
|
|
90
|
-
expanded = false,
|
|
91
|
-
async = false,
|
|
92
|
-
computed = false,
|
|
93
|
-
includeUnknown = false,
|
|
94
|
-
includeOffsets = false,
|
|
95
|
-
domParser = undefined,
|
|
96
|
-
includeTags = undefined,
|
|
97
|
-
excludeTags = undefined,
|
|
98
|
-
decompress: decompressConfig = undefined
|
|
99
|
-
} = {}
|
|
100
|
-
) {
|
|
101
|
-
dataView = getSelfContainedDataView(dataView);
|
|
102
|
-
decompressConfig = withDecompressBudget(decompressConfig);
|
|
103
|
-
|
|
104
|
-
const tagFilter = createTagFilter({includeTags, excludeTags});
|
|
105
|
-
const parsedGroups = Object.create(null);
|
|
106
|
-
const mergeSteps = [];
|
|
107
|
-
const deferredResults = Object.create(null);
|
|
108
|
-
const deferredPromises = [];
|
|
109
|
-
let pngTextIsAsync = false;
|
|
110
|
-
let thumbnailIfdTags = undefined;
|
|
111
|
-
let valueBudget = undefined;
|
|
112
|
-
let embeddedXmpStepForFlat = undefined;
|
|
113
|
-
let decompressedApplicationNotesSize = 0;
|
|
114
|
-
|
|
115
|
-
const {
|
|
116
|
-
fileType,
|
|
117
|
-
fileDataOffset,
|
|
118
|
-
jfifDataOffset,
|
|
119
|
-
tiffHeaderOffset,
|
|
120
|
-
iptcDataOffset,
|
|
121
|
-
xmpChunks,
|
|
122
|
-
iccChunks,
|
|
123
|
-
mpfDataOffset,
|
|
124
|
-
pngHeaderOffset,
|
|
125
|
-
pngTextChunks,
|
|
126
|
-
pngChunkOffsets,
|
|
127
|
-
vp8xChunkOffset,
|
|
128
|
-
gifHeaderOffset,
|
|
129
|
-
brobExifChunk,
|
|
130
|
-
brobXmpChunk,
|
|
131
|
-
jxlCodestreamOffset,
|
|
132
|
-
imageDimensionsOffset,
|
|
133
|
-
pixelInformationOffset,
|
|
134
|
-
metadataBlocks,
|
|
135
|
-
metadataTruncated,
|
|
136
|
-
exifDataView,
|
|
137
|
-
xmpDataView
|
|
138
|
-
} = ImageHeader.parseAppMarkers(dataView, async, expanded && includeOffsets);
|
|
139
|
-
|
|
140
|
-
const fileHasMetaData = hasPotentialMetaData({
|
|
141
|
-
fileType,
|
|
142
|
-
fileDataOffset,
|
|
143
|
-
jfifDataOffset,
|
|
144
|
-
tiffHeaderOffset,
|
|
145
|
-
iptcDataOffset,
|
|
146
|
-
xmpChunks,
|
|
147
|
-
iccChunks,
|
|
148
|
-
mpfDataOffset,
|
|
149
|
-
pngHeaderOffset,
|
|
150
|
-
pngTextChunks,
|
|
151
|
-
pngChunkOffsets,
|
|
152
|
-
vp8xChunkOffset,
|
|
153
|
-
gifHeaderOffset,
|
|
154
|
-
jxlCodestreamOffset,
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
if (
|
|
158
|
-
Constants.USE_JPEG
|
|
159
|
-
&& Constants.USE_FILE
|
|
160
|
-
&& fileDataOffset !== undefined
|
|
161
|
-
&& tagFilter.shouldParseGroup('file')
|
|
162
|
-
&& shouldReadFileTagsForFileTypeOnlyOptimization(includeTags)
|
|
163
|
-
) {
|
|
164
|
-
const readTags = FileTags.read(dataView, fileDataOffset);
|
|
165
|
-
const parsedFileTags = filterTagsForParse('file', readTags, tagFilter);
|
|
166
|
-
parsedGroups.file = parsedFileTags;
|
|
167
|
-
|
|
168
|
-
if (tagFilter.shouldReturnGroup('file')) {
|
|
169
|
-
mergeSteps.push({
|
|
170
|
-
type: 'mergeGroupAssign',
|
|
171
|
-
groupKey: 'file',
|
|
172
|
-
parsedTags: parsedFileTags,
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (
|
|
178
|
-
Constants.USE_JPEG
|
|
179
|
-
&& Constants.USE_JFIF
|
|
180
|
-
&& jfifDataOffset !== undefined
|
|
181
|
-
&& tagFilter.shouldParseGroup('jfif')
|
|
182
|
-
) {
|
|
183
|
-
const readTags = JfifTags.read(dataView, jfifDataOffset);
|
|
184
|
-
const parsedJfifTags = filterTagsForParse('jfif', readTags, tagFilter);
|
|
185
|
-
parsedGroups.jfif = parsedJfifTags;
|
|
186
|
-
|
|
187
|
-
if (tagFilter.shouldReturnGroup('jfif')) {
|
|
188
|
-
mergeSteps.push({
|
|
189
|
-
type: 'mergeGroupAssign',
|
|
190
|
-
groupKey: 'jfif',
|
|
191
|
-
parsedTags: parsedJfifTags,
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (
|
|
197
|
-
Constants.USE_EXIF
|
|
198
|
-
&& tiffHeaderOffset !== undefined
|
|
199
|
-
&& tagFilter.shouldParseGroup('exif')
|
|
200
|
-
) {
|
|
201
|
-
const {tags: readTags, byteOrder, valueBudget: exifValueBudget} = readExifTagsSafely(
|
|
202
|
-
exifDataView || dataView,
|
|
203
|
-
tiffHeaderOffset,
|
|
204
|
-
includeUnknown,
|
|
205
|
-
computed,
|
|
206
|
-
tagFilter
|
|
207
|
-
);
|
|
208
|
-
valueBudget = exifValueBudget;
|
|
209
|
-
if (readTags.Thumbnail) {
|
|
210
|
-
thumbnailIfdTags = readTags.Thumbnail;
|
|
211
|
-
delete readTags.Thumbnail;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
const parsedExifTags = filterTagsForParse('exif', readTags, tagFilter);
|
|
215
|
-
parsedGroups.exif = parsedExifTags;
|
|
216
|
-
|
|
217
|
-
const carriedGroups = readExifCarriedGroups(
|
|
218
|
-
parsedExifTags,
|
|
219
|
-
exifDataView || dataView,
|
|
220
|
-
tiffHeaderOffset,
|
|
221
|
-
byteOrder,
|
|
222
|
-
valueBudget,
|
|
223
|
-
{decompressed: false, hasIptcBlock: iptcDataOffset !== undefined}
|
|
224
|
-
);
|
|
225
|
-
for (let i = 0; i < EXIF_CARRIED_GROUP_ORDER.length; i++) {
|
|
226
|
-
const groupKey = EXIF_CARRIED_GROUP_ORDER[i];
|
|
227
|
-
if (carriedGroups[groupKey] === undefined) {
|
|
228
|
-
continue;
|
|
229
|
-
}
|
|
230
|
-
parsedGroups[groupKey] = carriedGroups[groupKey];
|
|
231
|
-
if (!tagFilter.shouldReturnGroup(groupKey)) {
|
|
232
|
-
continue;
|
|
233
|
-
}
|
|
234
|
-
if (groupKey === 'xmp') {
|
|
235
|
-
const step = {
|
|
236
|
-
type: 'mergeXmpGroupAssign',
|
|
237
|
-
parsedTags: carriedGroups.xmp,
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
if (expanded) {
|
|
241
|
-
mergeSteps.push(step);
|
|
242
|
-
} else {
|
|
243
|
-
embeddedXmpStepForFlat = step;
|
|
244
|
-
}
|
|
245
|
-
} else {
|
|
246
|
-
mergeSteps.push({
|
|
247
|
-
type: 'mergeGroupAssign',
|
|
248
|
-
groupKey,
|
|
249
|
-
parsedTags: carriedGroups[groupKey],
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
if (tagFilter.shouldReturnGroup('exif')) {
|
|
255
|
-
mergeSteps.push({
|
|
256
|
-
type: 'mergeGroupAssign',
|
|
257
|
-
groupKey: 'exif',
|
|
258
|
-
parsedTags: parsedExifTags,
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
if (!expanded && embeddedXmpStepForFlat) {
|
|
263
|
-
mergeSteps.push(embeddedXmpStepForFlat);
|
|
264
|
-
embeddedXmpStepForFlat = undefined;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
if (valueBudget === undefined && dataView !== undefined) {
|
|
269
|
-
valueBudget = getValueBudget(dataView);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
if (
|
|
273
|
-
Constants.USE_JPEG
|
|
274
|
-
&& Constants.USE_IPTC
|
|
275
|
-
&& iptcDataOffset !== undefined
|
|
276
|
-
&& tagFilter.shouldParseGroup('iptc')
|
|
277
|
-
) {
|
|
278
|
-
const readTags = IptcTags.read(dataView, iptcDataOffset, includeUnknown, tagFilter, valueBudget);
|
|
279
|
-
const parsedIptcTags = filterTagsForParse('iptc', readTags, tagFilter);
|
|
280
|
-
parsedGroups.iptc = parsedIptcTags;
|
|
281
|
-
|
|
282
|
-
if (tagFilter.shouldReturnGroup('iptc')) {
|
|
283
|
-
mergeSteps.push({
|
|
284
|
-
type: 'mergeGroupAssign',
|
|
285
|
-
groupKey: 'iptc',
|
|
286
|
-
parsedTags: parsedIptcTags,
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
if (
|
|
292
|
-
Constants.USE_XMP
|
|
293
|
-
&& hasXmpData(xmpChunks)
|
|
294
|
-
&& tagFilter.shouldParseGroup('xmp')
|
|
295
|
-
) {
|
|
296
|
-
const readTags = XmpTags.read(xmpDataView || dataView, xmpChunks, domParser);
|
|
297
|
-
const parsedXmpTags = filterTagsForParse('xmp', readTags, tagFilter);
|
|
298
|
-
parsedGroups.xmp = parsedXmpTags;
|
|
299
|
-
|
|
300
|
-
if (tagFilter.shouldReturnGroup('xmp')) {
|
|
301
|
-
mergeSteps.push({
|
|
302
|
-
type: 'mergeXmpGroupAssign',
|
|
303
|
-
parsedTags: parsedXmpTags,
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
const readEmbeddedExifThumbnail = getEmbeddedExifThumbnailReader(tagFilter, dataView);
|
|
309
|
-
|
|
310
|
-
if (
|
|
311
|
-
Constants.USE_JXL
|
|
312
|
-
&& Constants.USE_EXIF
|
|
313
|
-
&& brobExifChunk
|
|
314
|
-
&& tiffHeaderOffset === undefined
|
|
315
|
-
&& tagFilter.shouldParseGroup('exif')
|
|
316
|
-
&& async
|
|
317
|
-
) {
|
|
318
|
-
const compressedExifData = getBrobDataView(dataView, brobExifChunk);
|
|
319
|
-
deferredPromises.push(
|
|
320
|
-
decompress(compressedExifData, COMPRESSION_METHOD_BROTLI, undefined, 'dataview', decompressConfig)
|
|
321
|
-
.then((decompressedDataView) => {
|
|
322
|
-
const brobTiffHeaderOffset = getTiffHeaderOffset(decompressedDataView, 0);
|
|
323
|
-
addDecompressedValueAllowance(valueBudget, decompressedDataView.byteLength);
|
|
324
|
-
const {tags: readTags, byteOrder: brobByteOrder} = readExifTags(
|
|
325
|
-
decompressedDataView,
|
|
326
|
-
brobTiffHeaderOffset,
|
|
327
|
-
includeUnknown,
|
|
328
|
-
computed,
|
|
329
|
-
tagFilter,
|
|
330
|
-
valueBudget
|
|
331
|
-
);
|
|
332
|
-
const thumbnail = takeEmbeddedExifThumbnail(
|
|
333
|
-
readTags,
|
|
334
|
-
decompressedDataView,
|
|
335
|
-
brobTiffHeaderOffset,
|
|
336
|
-
readEmbeddedExifThumbnail
|
|
337
|
-
);
|
|
338
|
-
const carriedGroups = readEmbeddedExifCarriedGroups(
|
|
339
|
-
decompressedDataView,
|
|
340
|
-
readTags,
|
|
341
|
-
brobTiffHeaderOffset,
|
|
342
|
-
brobByteOrder,
|
|
343
|
-
valueBudget,
|
|
344
|
-
{decompressed: true, hasIptcBlock: false}
|
|
345
|
-
);
|
|
346
|
-
deferredResults.brobExif = {exifTags: readTags, carriedGroups, thumbnail};
|
|
347
|
-
})
|
|
348
|
-
.catch(() => {
|
|
349
|
-
deferredResults.brobExif = undefined;
|
|
350
|
-
})
|
|
351
|
-
);
|
|
352
|
-
mergeSteps.push({
|
|
353
|
-
type: 'mergeBrobExifDeferred',
|
|
354
|
-
deferredKey: 'brobExif',
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
if (
|
|
359
|
-
Constants.USE_JXL
|
|
360
|
-
&& Constants.USE_XMP
|
|
361
|
-
&& brobXmpChunk
|
|
362
|
-
&& !hasXmpData(xmpChunks)
|
|
363
|
-
&& tagFilter.shouldParseGroup('xmp')
|
|
364
|
-
&& async
|
|
365
|
-
) {
|
|
366
|
-
const compressedXmpData = getBrobDataView(dataView, brobXmpChunk);
|
|
367
|
-
deferredPromises.push(
|
|
368
|
-
decompress(compressedXmpData, COMPRESSION_METHOD_BROTLI, undefined, 'dataview', decompressConfig)
|
|
369
|
-
.then((decompressedDataView) => {
|
|
370
|
-
if (exceedsBrobXmpSizeBound(decompressedDataView.byteLength, dataView)) {
|
|
371
|
-
deferredResults.brobXmp = {};
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
374
|
-
deferredResults.brobXmp = XmpTags.read(
|
|
375
|
-
decompressedDataView,
|
|
376
|
-
[{dataOffset: 0, length: decompressedDataView.byteLength}],
|
|
377
|
-
domParser
|
|
378
|
-
);
|
|
379
|
-
})
|
|
380
|
-
.catch(() => {
|
|
381
|
-
deferredResults.brobXmp = {};
|
|
382
|
-
})
|
|
383
|
-
);
|
|
384
|
-
mergeSteps.push({
|
|
385
|
-
type: 'mergeBrobXmpDeferred',
|
|
386
|
-
deferredKey: 'brobXmp',
|
|
387
|
-
});
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
if (
|
|
391
|
-
Constants.USE_ICC
|
|
392
|
-
&& hasIccData(iccChunks)
|
|
393
|
-
&& tagFilter.shouldParseGroup('icc')
|
|
394
|
-
) {
|
|
395
|
-
const readTags = IccTags.read(dataView, iccChunks, async, decompressConfig);
|
|
396
|
-
if (isThenable(readTags)) {
|
|
397
|
-
if (!async) {
|
|
398
|
-
throw new Error('Promise is required when async mode is enabled.');
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
deferredPromises.push(readTags.then((resolvedTags) => {
|
|
402
|
-
deferredResults.iccApp = resolvedTags;
|
|
403
|
-
}));
|
|
404
|
-
mergeSteps.push({
|
|
405
|
-
type: 'mergeIccDeferred',
|
|
406
|
-
deferredKey: 'iccApp',
|
|
407
|
-
});
|
|
408
|
-
} else {
|
|
409
|
-
const parsedIccTags = filterTagsForParse('icc', readTags, tagFilter);
|
|
410
|
-
parsedGroups.icc = parsedIccTags;
|
|
411
|
-
if (tagFilter.shouldReturnGroup('icc')) {
|
|
412
|
-
mergeSteps.push({
|
|
413
|
-
type: 'mergeGroupAssign',
|
|
414
|
-
groupKey: 'icc',
|
|
415
|
-
parsedTags: parsedIccTags,
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
if (
|
|
422
|
-
Constants.USE_MPF
|
|
423
|
-
&& mpfDataOffset !== undefined
|
|
424
|
-
&& tagFilter.shouldParseGroup('mpf')
|
|
425
|
-
) {
|
|
426
|
-
const readMpfTags = MpfTags.read(
|
|
427
|
-
dataView,
|
|
428
|
-
mpfDataOffset,
|
|
429
|
-
includeUnknown,
|
|
430
|
-
computed,
|
|
431
|
-
tagFilter,
|
|
432
|
-
valueBudget
|
|
433
|
-
);
|
|
434
|
-
const parsedMpfTags = filterTagsForParse('mpf', readMpfTags, tagFilter);
|
|
435
|
-
parsedGroups.mpf = parsedMpfTags;
|
|
436
|
-
|
|
437
|
-
if (tagFilter.shouldReturnGroup('mpf')) {
|
|
438
|
-
mergeSteps.push({
|
|
439
|
-
type: 'mergeGroupAssign',
|
|
440
|
-
groupKey: 'mpf',
|
|
441
|
-
parsedTags: parsedMpfTags,
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
if (
|
|
447
|
-
Constants.USE_PNG
|
|
448
|
-
&& Constants.USE_PNG_FILE
|
|
449
|
-
&& pngHeaderOffset !== undefined
|
|
450
|
-
&& tagFilter.shouldParseGroup('png')
|
|
451
|
-
) {
|
|
452
|
-
const readTags = PngFileTags.read(dataView, pngHeaderOffset);
|
|
453
|
-
const parsedPngFileTags = filterTagsForParse('png', readTags, tagFilter);
|
|
454
|
-
parsedGroups.pngFile = parsedPngFileTags;
|
|
455
|
-
|
|
456
|
-
if (tagFilter.shouldReturnGroup('png')) {
|
|
457
|
-
mergeSteps.push({
|
|
458
|
-
type: 'mergePngFile',
|
|
459
|
-
parsedTags: parsedPngFileTags,
|
|
460
|
-
});
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
if (
|
|
465
|
-
Constants.USE_PNG
|
|
466
|
-
&& hasPngTextData(pngTextChunks)
|
|
467
|
-
&& (
|
|
468
|
-
tagFilter.shouldParseGroup('png')
|
|
469
|
-
|| tagFilter.shouldParseGroup('exif')
|
|
470
|
-
|| tagFilter.shouldParseGroup('iptc')
|
|
471
|
-
)
|
|
472
|
-
) {
|
|
473
|
-
const {readTags, embeddedExifTags, embeddedIptcTags, embeddedExifThumbnail, exifCarriedGroups, readTagsPromise} = PngTextTags.read(
|
|
474
|
-
dataView,
|
|
475
|
-
pngTextChunks,
|
|
476
|
-
async,
|
|
477
|
-
includeUnknown,
|
|
478
|
-
computed,
|
|
479
|
-
tagFilter,
|
|
480
|
-
decompressConfig,
|
|
481
|
-
valueBudget,
|
|
482
|
-
readEmbeddedExifThumbnail,
|
|
483
|
-
readEmbeddedExifCarriedGroups,
|
|
484
|
-
{
|
|
485
|
-
exif: Constants.USE_EXIF ? readExifTags : undefined,
|
|
486
|
-
iptc: Constants.USE_IPTC ? IptcTags.read : undefined,
|
|
487
|
-
}
|
|
488
|
-
);
|
|
489
|
-
pngTextIsAsync = !!readTagsPromise;
|
|
490
|
-
|
|
491
|
-
mergeSteps.push({
|
|
492
|
-
type: 'processPngTextReadTags',
|
|
493
|
-
readTags,
|
|
494
|
-
embeddedExifTags,
|
|
495
|
-
embeddedIptcTags,
|
|
496
|
-
embeddedExifThumbnail,
|
|
497
|
-
exifCarriedGroups,
|
|
498
|
-
});
|
|
499
|
-
|
|
500
|
-
if (readTagsPromise) {
|
|
501
|
-
deferredPromises.push(readTagsPromise.then((tagList) => {
|
|
502
|
-
deferredResults.pngTextTagList = tagList;
|
|
503
|
-
}));
|
|
504
|
-
mergeSteps.push({
|
|
505
|
-
type: 'processPngTextReadTagsDeferredList',
|
|
506
|
-
deferredKey: 'pngTextTagList',
|
|
507
|
-
});
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
if (
|
|
512
|
-
Constants.USE_PNG
|
|
513
|
-
&& pngChunkOffsets !== undefined
|
|
514
|
-
&& tagFilter.shouldParseGroup('png')
|
|
515
|
-
) {
|
|
516
|
-
const readTags = PngTags.read(dataView, pngChunkOffsets);
|
|
517
|
-
const parsedPngChunkTags = filterTagsForParse('png', readTags, tagFilter);
|
|
518
|
-
parsedGroups.pngChunk = parsedPngChunkTags;
|
|
519
|
-
|
|
520
|
-
if (tagFilter.shouldReturnGroup('png')) {
|
|
521
|
-
mergeSteps.push({
|
|
522
|
-
type: 'mergePngChunk',
|
|
523
|
-
parsedTags: parsedPngChunkTags,
|
|
524
|
-
});
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
if (
|
|
529
|
-
Constants.USE_WEBP
|
|
530
|
-
&& vp8xChunkOffset !== undefined
|
|
531
|
-
&& tagFilter.shouldParseGroup('riff')
|
|
532
|
-
) {
|
|
533
|
-
const readTags = Vp8xTags.read(dataView, vp8xChunkOffset);
|
|
534
|
-
const parsedRiffTags = filterTagsForParse('riff', readTags, tagFilter);
|
|
535
|
-
parsedGroups.riff = parsedRiffTags;
|
|
536
|
-
|
|
537
|
-
if (tagFilter.shouldReturnGroup('riff')) {
|
|
538
|
-
mergeSteps.push({
|
|
539
|
-
type: 'mergeGroupMerge',
|
|
540
|
-
groupKey: 'riff',
|
|
541
|
-
parsedTags: parsedRiffTags,
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
if (
|
|
547
|
-
Constants.USE_GIF
|
|
548
|
-
&& gifHeaderOffset !== undefined
|
|
549
|
-
&& tagFilter.shouldParseGroup('gif')
|
|
550
|
-
) {
|
|
551
|
-
const readTags = GifFileTags.read(dataView, gifHeaderOffset);
|
|
552
|
-
const parsedGifTags = filterTagsForParse('gif', readTags, tagFilter);
|
|
553
|
-
parsedGroups.gif = parsedGifTags;
|
|
554
|
-
|
|
555
|
-
if (tagFilter.shouldReturnGroup('gif')) {
|
|
556
|
-
mergeSteps.push({
|
|
557
|
-
type: 'mergeGroupMerge',
|
|
558
|
-
groupKey: 'gif',
|
|
559
|
-
parsedTags: parsedGifTags,
|
|
560
|
-
});
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
if (
|
|
565
|
-
Constants.USE_JXL
|
|
566
|
-
&& jxlCodestreamOffset !== undefined
|
|
567
|
-
&& tagFilter.shouldParseGroup('file')
|
|
568
|
-
) {
|
|
569
|
-
const readTags = JxlFileTags.read(dataView, jxlCodestreamOffset);
|
|
570
|
-
const parsedJxlFileTags = filterTagsForParse('file', readTags, tagFilter);
|
|
571
|
-
parsedGroups.file = parsedJxlFileTags;
|
|
572
|
-
|
|
573
|
-
if (tagFilter.shouldReturnGroup('file')) {
|
|
574
|
-
mergeSteps.push({
|
|
575
|
-
type: 'mergeGroupAssign',
|
|
576
|
-
groupKey: 'file',
|
|
577
|
-
parsedTags: parsedJxlFileTags,
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
if (
|
|
583
|
-
(Constants.USE_HEIC || Constants.USE_AVIF)
|
|
584
|
-
&& (imageDimensionsOffset !== undefined || pixelInformationOffset !== undefined)
|
|
585
|
-
&& tagFilter.shouldParseGroup('file')
|
|
586
|
-
) {
|
|
587
|
-
const readTags = IsoBmffFileTags.read(dataView, imageDimensionsOffset, pixelInformationOffset);
|
|
588
|
-
const parsedIsoBmffFileTags = filterTagsForParse('file', readTags, tagFilter);
|
|
589
|
-
parsedGroups.file = parsedIsoBmffFileTags;
|
|
590
|
-
|
|
591
|
-
if (tagFilter.shouldReturnGroup('file')) {
|
|
592
|
-
mergeSteps.push({
|
|
593
|
-
type: 'mergeGroupAssign',
|
|
594
|
-
groupKey: 'file',
|
|
595
|
-
parsedTags: parsedIsoBmffFileTags,
|
|
596
|
-
});
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
if (Constants.USE_EXIF) {
|
|
601
|
-
mergeSteps.push({type: 'gps'});
|
|
602
|
-
}
|
|
603
|
-
if (Constants.USE_EXIF || Constants.USE_XMP) {
|
|
604
|
-
mergeSteps.push({type: 'composite'});
|
|
605
|
-
}
|
|
606
|
-
mergeSteps.push({type: 'thumbnail'});
|
|
607
|
-
mergeSteps.push({type: 'fileType'});
|
|
608
|
-
|
|
609
|
-
if (expanded && includeOffsets) {
|
|
610
|
-
mergeSteps.push({
|
|
611
|
-
type: 'metadataRange',
|
|
612
|
-
metadataBlocks: getParsedMetadataBlocks(metadataBlocks, fileType),
|
|
613
|
-
metadataTruncated: !!metadataTruncated,
|
|
614
|
-
});
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
if (!fileHasMetaData) {
|
|
618
|
-
throw new exifErrors.MetadataMissingError();
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
const pipelineDependencies = {
|
|
622
|
-
objectAssign,
|
|
623
|
-
hasPngTextData,
|
|
624
|
-
filterTagsForParse,
|
|
625
|
-
filterTagsForReturn,
|
|
626
|
-
// A plain property here would keep the function alive for the bundler,
|
|
627
|
-
// so a build without Exif would still carry getGpsGroupFromExifTags.
|
|
628
|
-
getGpsGroupFromExifTags: Constants.USE_EXIF ? getGpsGroupFromExifTags : undefined,
|
|
629
|
-
// A plain property here would keep the import alive for the bundler, so
|
|
630
|
-
// a build with neither Exif nor XMP would still carry composite.js.
|
|
631
|
-
Composite: (Constants.USE_EXIF || Constants.USE_XMP) ? Composite : undefined,
|
|
632
|
-
// A plain property here would keep the import alive for the bundler, so
|
|
633
|
-
// a build without Exif thumbnails would still carry thumbnail.js.
|
|
634
|
-
Thumbnail: (Constants.USE_EXIF && Constants.USE_THUMBNAIL) ? Thumbnail : undefined,
|
|
635
|
-
};
|
|
636
|
-
|
|
637
|
-
if (async) {
|
|
638
|
-
assertPromiseSupport();
|
|
639
|
-
|
|
640
|
-
return Promise.all(deferredPromises).then(() => {
|
|
641
|
-
const tags = buildTagsFromMergeSteps({
|
|
642
|
-
mergeSteps,
|
|
643
|
-
deferredResults,
|
|
644
|
-
parsedGroups,
|
|
645
|
-
expanded,
|
|
646
|
-
tagFilter,
|
|
647
|
-
dataView,
|
|
648
|
-
tiffHeaderOffset,
|
|
649
|
-
exifDataView,
|
|
650
|
-
fileType,
|
|
651
|
-
pngTextChunks,
|
|
652
|
-
pngTextIsAsync,
|
|
653
|
-
thumbnailIfdTags,
|
|
654
|
-
deps: pipelineDependencies,
|
|
655
|
-
});
|
|
656
|
-
|
|
657
|
-
return tags;
|
|
658
|
-
});
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
return buildTagsFromMergeSteps({
|
|
662
|
-
mergeSteps,
|
|
663
|
-
deferredResults,
|
|
664
|
-
parsedGroups,
|
|
665
|
-
expanded,
|
|
666
|
-
tagFilter,
|
|
667
|
-
dataView,
|
|
668
|
-
tiffHeaderOffset,
|
|
669
|
-
exifDataView,
|
|
670
|
-
fileType,
|
|
671
|
-
pngTextChunks,
|
|
672
|
-
pngTextIsAsync,
|
|
673
|
-
thumbnailIfdTags,
|
|
674
|
-
deps: pipelineDependencies,
|
|
675
|
-
});
|
|
676
|
-
|
|
677
|
-
function shouldReadFileTagsForFileTypeOnlyOptimization(includeTagsOptions) {
|
|
678
|
-
if (!includeTagsOptions) {
|
|
679
|
-
return true;
|
|
680
|
-
}
|
|
681
|
-
const {composite, file} = includeTagsOptions;
|
|
682
|
-
if (composite === true || (Array.isArray(composite) && composite.length > 0)) {
|
|
683
|
-
return true;
|
|
684
|
-
}
|
|
685
|
-
return !(Array.isArray(file) && file.length === 1 && file[0] === 'FileType');
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
// Drops MakerNote.__offset once the maker note has been read, even when a
|
|
689
|
-
// reader throws.
|
|
690
|
-
function readExifCarriedGroups(parsedExifTags, exifTiffDataView, exifTiffHeaderOffset, exifByteOrder, exifValueBudget, source) {
|
|
691
|
-
const groups = {};
|
|
692
|
-
|
|
693
|
-
try {
|
|
694
|
-
if (
|
|
695
|
-
Constants.USE_IPTC
|
|
696
|
-
&& parsedExifTags['IPTC-NAA']
|
|
697
|
-
&& !source.hasIptcBlock
|
|
698
|
-
&& tagFilter.shouldParseGroup('iptc')
|
|
699
|
-
) {
|
|
700
|
-
const readIptcTags = IptcTags.read(
|
|
701
|
-
parsedExifTags['IPTC-NAA'].value,
|
|
702
|
-
0,
|
|
703
|
-
includeUnknown,
|
|
704
|
-
tagFilter,
|
|
705
|
-
exifValueBudget
|
|
706
|
-
);
|
|
707
|
-
groups.iptc = filterTagsForParse('iptc', readIptcTags, tagFilter);
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
if (
|
|
711
|
-
Constants.USE_XMP
|
|
712
|
-
&& parsedExifTags['ApplicationNotes']
|
|
713
|
-
&& isNumberArray(parsedExifTags['ApplicationNotes'].value)
|
|
714
|
-
&& !hasXmpData(xmpChunks)
|
|
715
|
-
&& tagFilter.shouldParseGroup('xmp')
|
|
716
|
-
&& (!source.decompressed || takeDecompressedApplicationNotesAllowance(parsedExifTags['ApplicationNotes'].value.length))
|
|
717
|
-
) {
|
|
718
|
-
const readXmpTags = XmpTags.read(
|
|
719
|
-
getByteString(parsedExifTags['ApplicationNotes'].value),
|
|
720
|
-
undefined,
|
|
721
|
-
domParser
|
|
722
|
-
);
|
|
723
|
-
groups.xmp = filterTagsForParse('xmp', readXmpTags, tagFilter);
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
if (
|
|
727
|
-
Constants.USE_PHOTOSHOP
|
|
728
|
-
&& parsedExifTags['ImageSourceData']
|
|
729
|
-
&& parsedExifTags['PhotoshopSettings']
|
|
730
|
-
&& Array.isArray(parsedExifTags['PhotoshopSettings'].value)
|
|
731
|
-
&& tagFilter.shouldParseGroup('photoshop')
|
|
732
|
-
) {
|
|
733
|
-
const readPhotoshopTags = PhotoshopTags.read(
|
|
734
|
-
parsedExifTags['PhotoshopSettings'].value,
|
|
735
|
-
includeUnknown,
|
|
736
|
-
tagFilter
|
|
737
|
-
);
|
|
738
|
-
groups.photoshop = filterTagsForParse('photoshop', readPhotoshopTags, tagFilter);
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
if (
|
|
742
|
-
Constants.USE_ICC
|
|
743
|
-
&& parsedExifTags['ICC_Profile']
|
|
744
|
-
&& !hasIccData(iccChunks)
|
|
745
|
-
&& tagFilter.shouldParseGroup('icc')
|
|
746
|
-
) {
|
|
747
|
-
const readIccTags = IccTags.read(
|
|
748
|
-
parsedExifTags['ICC_Profile'].value,
|
|
749
|
-
[{
|
|
750
|
-
offset: 0,
|
|
751
|
-
length: parsedExifTags['ICC_Profile'].value.length,
|
|
752
|
-
chunkNumber: 1,
|
|
753
|
-
chunksTotal: 1
|
|
754
|
-
}]
|
|
755
|
-
);
|
|
756
|
-
groups.icc = filterTagsForParse('icc', readIccTags, tagFilter);
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
if (
|
|
760
|
-
Constants.USE_MAKER_NOTES
|
|
761
|
-
&& parsedExifTags['MakerNote']
|
|
762
|
-
&& tagFilter.shouldParseGroup('makerNotes')
|
|
763
|
-
) {
|
|
764
|
-
if (hasCanonData(parsedExifTags)) {
|
|
765
|
-
groups.makerNotes = CanonTags.read(
|
|
766
|
-
exifTiffDataView,
|
|
767
|
-
exifTiffHeaderOffset,
|
|
768
|
-
parsedExifTags['MakerNote'].__offset,
|
|
769
|
-
exifByteOrder,
|
|
770
|
-
includeUnknown,
|
|
771
|
-
computed,
|
|
772
|
-
tagFilter,
|
|
773
|
-
exifValueBudget
|
|
774
|
-
);
|
|
775
|
-
} else if (hasPentaxType1Data(parsedExifTags)) {
|
|
776
|
-
groups.makerNotes = PentaxTags.read(
|
|
777
|
-
exifTiffDataView,
|
|
778
|
-
exifTiffHeaderOffset,
|
|
779
|
-
parsedExifTags['MakerNote'].__offset,
|
|
780
|
-
includeUnknown,
|
|
781
|
-
computed,
|
|
782
|
-
tagFilter,
|
|
783
|
-
exifValueBudget
|
|
784
|
-
);
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
} finally {
|
|
788
|
-
if (parsedExifTags['MakerNote']) {
|
|
789
|
-
delete parsedExifTags['MakerNote'].__offset;
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
return groups;
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
// The brob XMP bound covers the decompressed Exif blocks of a file together,
|
|
797
|
-
// so that several cannot each pass it.
|
|
798
|
-
function takeDecompressedApplicationNotesAllowance(byteLength) {
|
|
799
|
-
if (exceedsBrobXmpSizeBound(decompressedApplicationNotesSize + byteLength, dataView)) {
|
|
800
|
-
return false;
|
|
801
|
-
}
|
|
802
|
-
decompressedApplicationNotesSize += byteLength;
|
|
803
|
-
return true;
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
// A maker note that throws must drop the groups, not the Exif tags already read.
|
|
807
|
-
function readEmbeddedExifCarriedGroups(exifTiffDataView, readTags, exifTiffHeaderOffset, exifByteOrder, exifValueBudget, source) {
|
|
808
|
-
try {
|
|
809
|
-
return readExifCarriedGroups(
|
|
810
|
-
filterTagsForParse('exif', readTags, tagFilter),
|
|
811
|
-
exifTiffDataView,
|
|
812
|
-
exifTiffHeaderOffset,
|
|
813
|
-
exifByteOrder,
|
|
814
|
-
exifValueBudget,
|
|
815
|
-
source
|
|
816
|
-
);
|
|
817
|
-
} catch (error) {
|
|
818
|
-
return {};
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
// A caller-supplied DataView can be a window into a larger buffer. Extractors
|
|
824
|
-
// slice dataView.buffer, so copy the window out to keep them inside the image.
|
|
825
|
-
function getSelfContainedDataView(dataView) {
|
|
826
|
-
if (isWindowIntoLargerBuffer(dataView)) {
|
|
827
|
-
return getDataView(dataView.buffer.slice(dataView.byteOffset, dataView.byteOffset + dataView.byteLength));
|
|
828
|
-
}
|
|
829
|
-
return dataView;
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
function isWindowIntoLargerBuffer(dataView) {
|
|
833
|
-
return isDataViewLike(dataView)
|
|
834
|
-
&& ((dataView.byteOffset > 0) || (dataView.byteLength < dataView.buffer.byteLength));
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
// A DataView from another realm, an iframe for example, fails instanceof, so
|
|
838
|
-
// match on the shape instead. A typed array has no getUint8, so it is not
|
|
839
|
-
// treated as a window here.
|
|
840
|
-
function isDataViewLike(dataView) {
|
|
841
|
-
return !!dataView
|
|
842
|
-
&& (typeof dataView.getUint8 === 'function')
|
|
843
|
-
&& (typeof dataView.byteOffset === 'number')
|
|
844
|
-
&& (typeof dataView.byteLength === 'number')
|
|
845
|
-
&& !!dataView.buffer
|
|
846
|
-
&& (typeof dataView.buffer.slice === 'function');
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
function getBrobDataView(dataView, brobChunk) {
|
|
850
|
-
// The box length is untrusted, so bound the view by the bytes present. The
|
|
851
|
-
// JXL header parser never reports a dataOffset past the end of the view.
|
|
852
|
-
const length = Math.max(0, Math.min(brobChunk.length, dataView.byteLength - brobChunk.dataOffset));
|
|
853
|
-
return new DataView(dataView.buffer, dataView.byteOffset + brobChunk.dataOffset, length);
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
function exceedsBrobXmpSizeBound(byteLength, inputDataView) {
|
|
857
|
-
return byteLength > BROB_XMP_SIZE_PER_INPUT_SIZE * inputDataView.byteLength + BROB_XMP_SIZE_ALLOWANCE;
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
function readExifTagsSafely(dataView, tiffHeaderOffset, includeUnknown, computed, tagFilter) {
|
|
861
|
-
// Created outside the try so values decoded before a throw still count
|
|
862
|
-
// against the budget that the maker note and MPF reads draw from. The data
|
|
863
|
-
// view is only missing in unit tests that fake the tag readers.
|
|
864
|
-
const valueBudget = dataView === undefined ? undefined : getValueBudget(dataView);
|
|
865
|
-
try {
|
|
866
|
-
const {tags, byteOrder} = readExifTags(dataView, tiffHeaderOffset, includeUnknown, computed, tagFilter, valueBudget);
|
|
867
|
-
return {tags, byteOrder, valueBudget};
|
|
868
|
-
} catch (error) {
|
|
869
|
-
// A malformed TIFF header (an out-of-bounds offset or an invalid byte
|
|
870
|
-
// order marker, e.g. from a HEIC/AVIF iloc that does not point at real
|
|
871
|
-
// Exif) must not abort the whole parse. Skip Exif instead, but keep the
|
|
872
|
-
// same {tags, byteOrder, valueBudget} shape so callers can destructure
|
|
873
|
-
// safely.
|
|
874
|
-
return {tags: {}, byteOrder: ByteOrder.BIG_ENDIAN, valueBudget};
|
|
875
|
-
}
|
|
73
|
+
export function loadView(dataView, options = {}) {
|
|
74
|
+
return readView(getDefaultComposition(), dataView, options, getEnvironment());
|
|
876
75
|
}
|
|
877
76
|
|
|
878
|
-
function
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
);
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
// Only the IFDs Tags.read walks; the MPF and maker note readers carry their own
|
|
892
|
-
// dictionaries. The thumbnail one must be there whenever shouldReadThumbnailIfd
|
|
893
|
-
// is true, since reading an IFD without its dictionary throws.
|
|
894
|
-
function getExifTagNames() {
|
|
895
|
-
// Assigned rather than computed keys, which Babel compiles to a helper call each.
|
|
896
|
-
const tagNames = {};
|
|
897
|
-
tagNames[IFD_TYPE_0TH] = TAG_NAMES_0TH_AND_EXIF_IFDS;
|
|
898
|
-
tagNames[IFD_TYPE_EXIF] = TAG_NAMES_0TH_AND_EXIF_IFDS;
|
|
899
|
-
tagNames[IFD_TYPE_GPS] = TagNamesGpsIfd;
|
|
900
|
-
tagNames[IFD_TYPE_INTEROPERABILITY] = TagNamesInteroperabilityIfd;
|
|
901
|
-
if (Constants.USE_THUMBNAIL) {
|
|
902
|
-
tagNames[IFD_TYPE_1ST] = TagNames0thIfd;
|
|
77
|
+
function getDefaultComposition() {
|
|
78
|
+
const tables = getDefaultTables();
|
|
79
|
+
const entries = getTableEntries(tables);
|
|
80
|
+
if (defaultComposition === undefined || !haveSameItems(entries, defaultCompositionEntries)) {
|
|
81
|
+
defaultComposition = Composition.createComposition(tables);
|
|
82
|
+
defaultComposition.isHiddenInSyncMode = createIsHiddenInSyncMode(tables.formats);
|
|
83
|
+
if (Constants.USE_EXIF && Constants.USE_THUMBNAIL) {
|
|
84
|
+
defaultComposition.mergeModes = objectAssign(Object.create(null), defaultComposition.mergeModes, {thumbnail: addThumbnailWithAlias});
|
|
85
|
+
}
|
|
86
|
+
defaultCompositionEntries = entries;
|
|
903
87
|
}
|
|
904
|
-
return
|
|
88
|
+
return defaultComposition;
|
|
905
89
|
}
|
|
906
90
|
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
91
|
+
// Thumbnail is the enumerable key existing code reads; thumbnail is the same
|
|
92
|
+
// object, left out of Object.keys and JSON.stringify so the output is unchanged.
|
|
93
|
+
function addThumbnailWithAlias(tags, block, context) {
|
|
94
|
+
removeThumbnailTag(tags);
|
|
910
95
|
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
96
|
+
const selected = getSelectedThumbnail(context);
|
|
97
|
+
if (selected) {
|
|
98
|
+
tags.Thumbnail = selected;
|
|
99
|
+
if (!Object.prototype.hasOwnProperty.call(tags, 'thumbnail')) {
|
|
100
|
+
Object.defineProperty(tags, 'thumbnail', {value: selected, writable: true, configurable: true});
|
|
101
|
+
}
|
|
915
102
|
}
|
|
916
|
-
const format = fileType && fileType.value;
|
|
917
|
-
const isCapped = metadataBlocks.length >= MAX_METADATA_BLOCKS;
|
|
918
|
-
const lastIndex = metadataBlocks.length - 1;
|
|
919
|
-
return metadataBlocks.filter((block, index) => isParsedMetadataBlock(format, block.type)
|
|
920
|
-
// At the cap the last block was widened over every later block, so it stays.
|
|
921
|
-
|| (isCapped && index === lastIndex));
|
|
922
|
-
}
|
|
923
103
|
|
|
924
|
-
|
|
925
|
-
switch (blockType) {
|
|
926
|
-
case 'file':
|
|
927
|
-
return format === 'png' ? Constants.USE_PNG_FILE : Constants.USE_FILE;
|
|
928
|
-
case 'exif':
|
|
929
|
-
return Constants.USE_EXIF;
|
|
930
|
-
case 'jfif':
|
|
931
|
-
return Constants.USE_JFIF;
|
|
932
|
-
case 'xmp':
|
|
933
|
-
return Constants.USE_XMP;
|
|
934
|
-
case 'iptc':
|
|
935
|
-
return Constants.USE_IPTC;
|
|
936
|
-
case 'icc':
|
|
937
|
-
return Constants.USE_ICC;
|
|
938
|
-
case 'mpf':
|
|
939
|
-
return Constants.USE_MPF;
|
|
940
|
-
default:
|
|
941
|
-
return true;
|
|
942
|
-
}
|
|
104
|
+
return tags;
|
|
943
105
|
}
|
|
944
106
|
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
}
|
|
953
|
-
let copiedThumbnailSize = 0;
|
|
954
|
-
return (dataView, thumbnailIfdTags, tiffHeaderOffset) => {
|
|
955
|
-
const parsedThumbnailIfdTags = filterTagsForParse('thumbnail', thumbnailIfdTags, tagFilter);
|
|
956
|
-
const lengthTag = parsedThumbnailIfdTags.JPEGInterchangeFormatLength;
|
|
957
|
-
const sizeBound =
|
|
958
|
-
EMBEDDED_THUMBNAIL_SIZE_PER_INPUT_SIZE * inputDataView.byteLength + EMBEDDED_THUMBNAIL_SIZE_ALLOWANCE;
|
|
959
|
-
if (!hasLengthWithin(lengthTag, sizeBound - copiedThumbnailSize)) {
|
|
960
|
-
return parsedThumbnailIfdTags;
|
|
961
|
-
}
|
|
962
|
-
const thumbnail = Thumbnail.get(dataView, parsedThumbnailIfdTags, tiffHeaderOffset);
|
|
963
|
-
if (thumbnail.image) {
|
|
964
|
-
copiedThumbnailSize += lengthTag.value;
|
|
965
|
-
}
|
|
966
|
-
return thumbnail;
|
|
107
|
+
// Each helper is behind the flags of the groups that read it, so that a
|
|
108
|
+
// custom build without them folds the helper's module away.
|
|
109
|
+
function getEnvironment() {
|
|
110
|
+
return {
|
|
111
|
+
getDomParser: Constants.USE_XMP ? DOMParser.get : undefined,
|
|
112
|
+
getBase64Image: (Constants.USE_EXIF && Constants.USE_THUMBNAIL) || Constants.USE_MPF ? getBase64Image : undefined,
|
|
113
|
+
createTagFilter,
|
|
967
114
|
};
|
|
968
115
|
}
|
|
969
116
|
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
117
|
+
// Every format and group, each inside its build gate so that a custom build
|
|
118
|
+
// folds the import away. A format-bound reader has its own gate, so the jpeg
|
|
119
|
+
// and png formats are listed by header and readers rather than whole.
|
|
120
|
+
function getDefaultTables() {
|
|
121
|
+
return {
|
|
122
|
+
formats: [
|
|
123
|
+
Constants.USE_TIFF ? tiff : undefined,
|
|
124
|
+
Constants.USE_JPEG ? {
|
|
125
|
+
header: jpegHeader,
|
|
126
|
+
readers: [
|
|
127
|
+
Constants.USE_FILE ? file : undefined,
|
|
128
|
+
Constants.USE_JFIF ? jfif : undefined,
|
|
129
|
+
],
|
|
130
|
+
} : undefined,
|
|
131
|
+
Constants.USE_PNG ? {
|
|
132
|
+
header: pngHeader,
|
|
133
|
+
readers: [
|
|
134
|
+
Constants.USE_PNG_FILE ? pngFile : undefined,
|
|
135
|
+
pngText,
|
|
136
|
+
pngChunk,
|
|
137
|
+
],
|
|
138
|
+
} : undefined,
|
|
139
|
+
Constants.USE_HEIC ? heic : undefined,
|
|
140
|
+
Constants.USE_AVIF ? avif : undefined,
|
|
141
|
+
Constants.USE_JXL ? jxl : undefined,
|
|
142
|
+
Constants.USE_WEBP ? webp : undefined,
|
|
143
|
+
Constants.USE_GIF ? gif : undefined,
|
|
144
|
+
Constants.USE_XMP ? xml : undefined,
|
|
145
|
+
].filter(Boolean),
|
|
146
|
+
groups: [
|
|
147
|
+
Constants.USE_EXIF ? exif : undefined,
|
|
148
|
+
Constants.USE_IPTC ? iptc : undefined,
|
|
149
|
+
Constants.USE_XMP ? xmp : undefined,
|
|
150
|
+
Constants.USE_ICC ? icc : undefined,
|
|
151
|
+
Constants.USE_MPF ? mpf : undefined,
|
|
152
|
+
Constants.USE_PHOTOSHOP ? photoshop : undefined,
|
|
153
|
+
Constants.USE_MAKER_NOTES ? makerNotes : undefined,
|
|
154
|
+
Constants.USE_EXIF && Constants.USE_THUMBNAIL ? thumbnail : undefined,
|
|
155
|
+
Constants.USE_EXIF ? gps : undefined,
|
|
156
|
+
Constants.USE_EXIF || Constants.USE_XMP ? composite : undefined,
|
|
157
|
+
].filter(Boolean),
|
|
158
|
+
};
|
|
982
159
|
}
|
|
983
160
|
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
161
|
+
// The jpeg and png formats are new objects on every call, so they compare by
|
|
162
|
+
// header and readers.
|
|
163
|
+
function getTableEntries({formats, groups}) {
|
|
164
|
+
let entries = [];
|
|
165
|
+
for (let i = 0; i < formats.length; i++) {
|
|
166
|
+
entries = entries.concat([formats[i].header], formats[i].readers);
|
|
987
167
|
}
|
|
988
|
-
|
|
989
|
-
return filterTags(groupKey, readTags, tagFilter.shouldReturnTag);
|
|
168
|
+
return entries.concat(groups);
|
|
990
169
|
}
|
|
991
170
|
|
|
992
|
-
function
|
|
993
|
-
if (
|
|
994
|
-
return
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
const filteredTags = {};
|
|
998
|
-
|
|
999
|
-
for (const tagName in readTags) {
|
|
1000
|
-
const tagValue = readTags[tagName];
|
|
1001
|
-
const tagId = getTagId(tagValue);
|
|
1002
|
-
|
|
1003
|
-
if (matchesTag(groupKey, tagName, tagId)) {
|
|
1004
|
-
setProperty(filteredTags, tagName, tagValue);
|
|
1005
|
-
}
|
|
171
|
+
function haveSameItems(items, otherItems) {
|
|
172
|
+
if (items.length !== otherItems.length) {
|
|
173
|
+
return false;
|
|
1006
174
|
}
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
function getTagId(tagValue) {
|
|
1011
|
-
if (!tagValue) {
|
|
1012
|
-
return undefined;
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
if (Array.isArray(tagValue)) {
|
|
1016
|
-
if (tagValue.length === 0) {
|
|
1017
|
-
return undefined;
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
|
-
return tagValue[0].id;
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
return tagValue.id;
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
function hasPotentialMetaData({
|
|
1028
|
-
fileType,
|
|
1029
|
-
fileDataOffset,
|
|
1030
|
-
jfifDataOffset,
|
|
1031
|
-
tiffHeaderOffset,
|
|
1032
|
-
iptcDataOffset,
|
|
1033
|
-
xmpChunks,
|
|
1034
|
-
iccChunks,
|
|
1035
|
-
mpfDataOffset,
|
|
1036
|
-
pngHeaderOffset,
|
|
1037
|
-
pngTextChunks,
|
|
1038
|
-
pngChunkOffsets,
|
|
1039
|
-
vp8xChunkOffset,
|
|
1040
|
-
gifHeaderOffset,
|
|
1041
|
-
jxlCodestreamOffset,
|
|
1042
|
-
imageDimensionsOffset,
|
|
1043
|
-
pixelInformationOffset,
|
|
1044
|
-
}) {
|
|
1045
|
-
return !!fileType
|
|
1046
|
-
|| (
|
|
1047
|
-
Constants.USE_JPEG
|
|
1048
|
-
&& Constants.USE_FILE
|
|
1049
|
-
&& fileDataOffset !== undefined
|
|
1050
|
-
)
|
|
1051
|
-
|| (
|
|
1052
|
-
Constants.USE_JPEG
|
|
1053
|
-
&& Constants.USE_JFIF
|
|
1054
|
-
&& jfifDataOffset !== undefined
|
|
1055
|
-
)
|
|
1056
|
-
|| (
|
|
1057
|
-
Constants.USE_EXIF
|
|
1058
|
-
&& tiffHeaderOffset !== undefined
|
|
1059
|
-
)
|
|
1060
|
-
|| (
|
|
1061
|
-
Constants.USE_JPEG
|
|
1062
|
-
&& Constants.USE_IPTC
|
|
1063
|
-
&& iptcDataOffset !== undefined
|
|
1064
|
-
)
|
|
1065
|
-
|| (
|
|
1066
|
-
Constants.USE_XMP
|
|
1067
|
-
&& hasXmpData(xmpChunks)
|
|
1068
|
-
)
|
|
1069
|
-
|| (
|
|
1070
|
-
Constants.USE_ICC
|
|
1071
|
-
&& hasIccData(iccChunks)
|
|
1072
|
-
)
|
|
1073
|
-
|| (
|
|
1074
|
-
Constants.USE_MPF
|
|
1075
|
-
&& mpfDataOffset !== undefined
|
|
1076
|
-
)
|
|
1077
|
-
|| (
|
|
1078
|
-
Constants.USE_PNG
|
|
1079
|
-
&& Constants.USE_PNG_FILE
|
|
1080
|
-
&& pngHeaderOffset !== undefined
|
|
1081
|
-
)
|
|
1082
|
-
|| (
|
|
1083
|
-
Constants.USE_PNG
|
|
1084
|
-
&& hasPngTextData(pngTextChunks)
|
|
1085
|
-
)
|
|
1086
|
-
|| (
|
|
1087
|
-
Constants.USE_PNG
|
|
1088
|
-
&& pngChunkOffsets !== undefined
|
|
1089
|
-
)
|
|
1090
|
-
|| (
|
|
1091
|
-
Constants.USE_WEBP
|
|
1092
|
-
&& vp8xChunkOffset !== undefined
|
|
1093
|
-
)
|
|
1094
|
-
|| (
|
|
1095
|
-
Constants.USE_GIF
|
|
1096
|
-
&& gifHeaderOffset !== undefined
|
|
1097
|
-
)
|
|
1098
|
-
|| (
|
|
1099
|
-
Constants.USE_JXL
|
|
1100
|
-
&& jxlCodestreamOffset !== undefined
|
|
1101
|
-
)
|
|
1102
|
-
|| (
|
|
1103
|
-
(Constants.USE_HEIC || Constants.USE_AVIF)
|
|
1104
|
-
&& (imageDimensionsOffset !== undefined || pixelInformationOffset !== undefined)
|
|
1105
|
-
);
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
function getGpsGroupFromExifTags(exifTags) {
|
|
1109
|
-
let gps = undefined;
|
|
1110
|
-
|
|
1111
|
-
if (exifTags.GPSLatitude && exifTags.GPSLatitudeRef) {
|
|
1112
|
-
gps = gps || {};
|
|
1113
|
-
try {
|
|
1114
|
-
gps.Latitude = getCalculatedGpsValue(exifTags.GPSLatitude.value);
|
|
1115
|
-
if (exifTags.GPSLatitudeRef.value.join('') === 'S') {
|
|
1116
|
-
gps.Latitude = -gps.Latitude;
|
|
1117
|
-
}
|
|
1118
|
-
} catch (error) {
|
|
1119
|
-
// Ignore.
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
|
-
if (exifTags.GPSLongitude && exifTags.GPSLongitudeRef) {
|
|
1124
|
-
gps = gps || {};
|
|
1125
|
-
try {
|
|
1126
|
-
gps.Longitude = getCalculatedGpsValue(exifTags.GPSLongitude.value);
|
|
1127
|
-
if (exifTags.GPSLongitudeRef.value.join('') === 'W') {
|
|
1128
|
-
gps.Longitude = -gps.Longitude;
|
|
1129
|
-
}
|
|
1130
|
-
} catch (error) {
|
|
1131
|
-
// Ignore.
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
|
-
if (exifTags.GPSAltitude && exifTags.GPSAltitudeRef) {
|
|
1136
|
-
gps = gps || {};
|
|
1137
|
-
try {
|
|
1138
|
-
gps.Altitude =
|
|
1139
|
-
exifTags.GPSAltitude.value[0] / exifTags.GPSAltitude.value[1];
|
|
1140
|
-
if (exifTags.GPSAltitudeRef.value === 1) {
|
|
1141
|
-
gps.Altitude = -gps.Altitude;
|
|
1142
|
-
}
|
|
1143
|
-
} catch (error) {
|
|
1144
|
-
// Ignore.
|
|
175
|
+
for (let i = 0; i < items.length; i++) {
|
|
176
|
+
if (items[i] !== otherItems[i]) {
|
|
177
|
+
return false;
|
|
1145
178
|
}
|
|
1146
179
|
}
|
|
1147
|
-
|
|
1148
|
-
if (!gps) {
|
|
1149
|
-
return undefined;
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
return gps;
|
|
1153
|
-
}
|
|
1154
|
-
|
|
1155
|
-
// ASCII values hold strings and holes, values of two or more rationals hold
|
|
1156
|
-
// number pairs: neither converts to the character codes of an XMP packet.
|
|
1157
|
-
function isNumberArray(value) {
|
|
1158
|
-
return Array.isArray(value) && typeof value[0] === 'number';
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
function hasXmpData(xmpChunks) {
|
|
1162
|
-
return Array.isArray(xmpChunks) && xmpChunks.length > 0;
|
|
1163
|
-
}
|
|
1164
|
-
|
|
1165
|
-
function hasIccData(iccDataOffsets) {
|
|
1166
|
-
return Array.isArray(iccDataOffsets) && iccDataOffsets.length > 0;
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
function hasCanonData(tags) {
|
|
1170
|
-
return tags['Make'] && tags['Make'].value && Array.isArray(tags['Make'].value) && tags['Make'].value[0] === 'Canon'
|
|
1171
|
-
&& tags['MakerNote'] && tags['MakerNote'].__offset;
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
|
-
function hasPentaxType1Data(tags) {
|
|
1175
|
-
const PENTAX_ID_STRING = 'PENTAX ';
|
|
1176
|
-
return Array.isArray(tags['MakerNote'].value)
|
|
1177
|
-
&& tags['MakerNote'].value.length > PENTAX_ID_STRING.length
|
|
1178
|
-
&& getStringValueFromArray(tags['MakerNote'].value.slice(0, PENTAX_ID_STRING.length)) === PENTAX_ID_STRING
|
|
1179
|
-
&& tags['MakerNote'].__offset;
|
|
1180
|
-
}
|
|
1181
|
-
|
|
1182
|
-
function hasPngTextData(pngTextChunks) {
|
|
1183
|
-
return Array.isArray(pngTextChunks) && pngTextChunks.length > 0;
|
|
180
|
+
return true;
|
|
1184
181
|
}
|