exifreader 4.52.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.
@@ -0,0 +1,321 @@
1
+ /* This Source Code Form is subject to the terms of the Mozilla Public
2
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
+
5
+ // Type and count come from CIPA DC-008-2019 §4.6.3 to §4.6.7, level from the
6
+ // compressed column of §4.6.8 Tables 17 to 20: the support level whenever the
7
+ // tag's IFD is written (M mandatory, R recommended, O optional, N and J not
8
+ // allowed). thumbnailLevel is present only where Table 21 (1st IFD) gives a
9
+ // different level. writable: false means the tag is defined outside DC-008 by
10
+ // the source named on its line, which this table does not draw on.
11
+ // Such a tag is N when it describes how a TIFF stores its image data or points
12
+ // at data the writer does not carry, J when a JPEG carries its payload in a
13
+ // marker segment, else O.
14
+ // DEFAULT_FROM_SOF: the value comes from the JPEG SOF segment.
15
+ // DEFAULT_COMPUTED: the writer computes the value (an offset or a length).
16
+
17
+ const DEFAULT_FROM_SOF = 'fromSof';
18
+ const DEFAULT_COMPUTED = 'computed';
19
+
20
+ const tags = [
21
+ {id: 0x000b, ifd: '0th', name: 'ProcessingSoftware', level: 'O', writable: false}, // vendor
22
+ {id: 0x00fe, ifd: '0th', name: 'SubfileType', level: 'N', writable: false}, // TIFF 6.0
23
+ {id: 0x00ff, ifd: '0th', name: 'OldSubfileType', level: 'N', writable: false}, // TIFF 6.0
24
+ {id: 0x0100, ifd: '0th', name: 'ImageWidth', type: ['SHORT', 'LONG'], count: 1, level: 'J'},
25
+ {id: 0x0101, ifd: '0th', name: 'ImageLength', type: ['SHORT', 'LONG'], count: 1, level: 'J'},
26
+ {id: 0x0102, ifd: '0th', name: 'BitsPerSample', type: 'SHORT', count: 3, level: 'J'},
27
+ {id: 0x0103, ifd: '0th', name: 'Compression', type: 'SHORT', count: 1, level: 'J', thumbnailLevel: 'M', default: 6},
28
+ {id: 0x0106, ifd: '0th', name: 'PhotometricInterpretation', type: 'SHORT', count: 1, level: 'N', thumbnailLevel: 'J'},
29
+ {id: 0x0107, ifd: '0th', name: 'Thresholding', level: 'N', writable: false}, // TIFF 6.0
30
+ {id: 0x0108, ifd: '0th', name: 'CellWidth', level: 'N', writable: false}, // TIFF 6.0
31
+ {id: 0x0109, ifd: '0th', name: 'CellLength', level: 'N', writable: false}, // TIFF 6.0
32
+ {id: 0x010a, ifd: '0th', name: 'FillOrder', level: 'N', writable: false}, // TIFF 6.0
33
+ {id: 0x010d, ifd: '0th', name: 'DocumentName', level: 'O', writable: false}, // TIFF 6.0
34
+ {id: 0x010e, ifd: '0th', name: 'ImageDescription', type: 'ASCII', count: 'any', level: 'R', thumbnailLevel: 'O'},
35
+ {id: 0x010f, ifd: '0th', name: 'Make', type: 'ASCII', count: 'any', level: 'R', thumbnailLevel: 'O'},
36
+ {id: 0x0110, ifd: '0th', name: 'Model', type: 'ASCII', count: 'any', level: 'R', thumbnailLevel: 'O'},
37
+ {id: 0x0111, ifd: '0th', name: 'StripOffsets', type: ['SHORT', 'LONG'], count: 'any', level: 'N'},
38
+ {id: 0x0112, ifd: '0th', name: 'Orientation', type: 'SHORT', count: 1, level: 'R', thumbnailLevel: 'O'},
39
+ {id: 0x0115, ifd: '0th', name: 'SamplesPerPixel', type: 'SHORT', count: 1, level: 'J'},
40
+ {id: 0x0116, ifd: '0th', name: 'RowsPerStrip', type: ['SHORT', 'LONG'], count: 1, level: 'N'},
41
+ {id: 0x0117, ifd: '0th', name: 'StripByteCounts', type: ['SHORT', 'LONG'], count: 'any', level: 'N'},
42
+ {id: 0x0118, ifd: '0th', name: 'MinSampleValue', level: 'N', writable: false}, // TIFF 6.0
43
+ {id: 0x0119, ifd: '0th', name: 'MaxSampleValue', level: 'N', writable: false}, // TIFF 6.0
44
+ {id: 0x011a, ifd: '0th', name: 'XResolution', type: 'RATIONAL', count: 1, level: 'M', default: [72, 1]},
45
+ {id: 0x011b, ifd: '0th', name: 'YResolution', type: 'RATIONAL', count: 1, level: 'M', default: [72, 1]},
46
+ {id: 0x011c, ifd: '0th', name: 'PlanarConfiguration', type: 'SHORT', count: 1, level: 'J'},
47
+ {id: 0x011d, ifd: '0th', name: 'PageName', level: 'O', writable: false}, // TIFF 6.0
48
+ {id: 0x011e, ifd: '0th', name: 'XPosition', level: 'O', writable: false}, // TIFF 6.0
49
+ {id: 0x011f, ifd: '0th', name: 'YPosition', level: 'O', writable: false}, // TIFF 6.0
50
+ {id: 0x0122, ifd: '0th', name: 'GrayResponseUnit', level: 'N', writable: false}, // TIFF 6.0
51
+ {id: 0x0128, ifd: '0th', name: 'ResolutionUnit', type: 'SHORT', count: 1, level: 'M', default: 2},
52
+ {id: 0x0129, ifd: '0th', name: 'PageNumber', level: 'O', writable: false}, // TIFF 6.0
53
+ {id: 0x012d, ifd: '0th', name: 'TransferFunction', type: 'SHORT', count: 768, level: 'O'},
54
+ {id: 0x0131, ifd: '0th', name: 'Software', type: 'ASCII', count: 'any', level: 'O'},
55
+ {id: 0x0132, ifd: '0th', name: 'DateTime', type: 'ASCII', count: 20, level: 'R', thumbnailLevel: 'O'},
56
+ {id: 0x013b, ifd: '0th', name: 'Artist', type: 'ASCII', count: 'any', level: 'O'},
57
+ {id: 0x013c, ifd: '0th', name: 'HostComputer', level: 'O', writable: false}, // TIFF 6.0
58
+ {id: 0x013d, ifd: '0th', name: 'Predictor', level: 'N', writable: false}, // TIFF 6.0
59
+ {id: 0x013e, ifd: '0th', name: 'WhitePoint', type: 'RATIONAL', count: 2, level: 'O'},
60
+ {id: 0x013f, ifd: '0th', name: 'PrimaryChromaticities', type: 'RATIONAL', count: 6, level: 'O'},
61
+ {id: 0x0141, ifd: '0th', name: 'HalftoneHints', level: 'O', writable: false}, // TIFF 6.0
62
+ {id: 0x0142, ifd: '0th', name: 'TileWidth', level: 'N', writable: false}, // TIFF 6.0
63
+ {id: 0x0143, ifd: '0th', name: 'TileLength', level: 'N', writable: false}, // TIFF 6.0
64
+ {id: 0x014a, ifd: '0th', name: 'A100DataOffset', level: 'N', writable: false}, // vendor
65
+ {id: 0x014c, ifd: '0th', name: 'InkSet', level: 'N', writable: false}, // TIFF 6.0
66
+ {id: 0x0151, ifd: '0th', name: 'TargetPrinter', level: 'O', writable: false}, // TIFF 6.0
67
+ {id: 0x0152, ifd: '0th', name: 'ExtraSamples', level: 'N', writable: false}, // TIFF 6.0
68
+ {id: 0x0153, ifd: '0th', name: 'SampleFormat', level: 'N', writable: false}, // TIFF 6.0
69
+ {id: 0x0201, ifd: '0th', name: 'JPEGInterchangeFormat', type: 'LONG', count: 1, level: 'N', thumbnailLevel: 'M', default: DEFAULT_COMPUTED},
70
+ {id: 0x0202, ifd: '0th', name: 'JPEGInterchangeFormatLength', type: 'LONG', count: 1, level: 'N', thumbnailLevel: 'M', default: DEFAULT_COMPUTED},
71
+ {id: 0x0211, ifd: '0th', name: 'YCbCrCoefficients', type: 'RATIONAL', count: 3, level: 'O'},
72
+ {id: 0x0212, ifd: '0th', name: 'YCbCrSubSampling', type: 'SHORT', count: 2, level: 'J'},
73
+ {id: 0x0213, ifd: '0th', name: 'YCbCrPositioning', type: 'SHORT', count: 1, level: 'M', thumbnailLevel: 'O', default: 1},
74
+ {id: 0x0214, ifd: '0th', name: 'ReferenceBlackWhite', type: 'RATIONAL', count: 6, level: 'O'},
75
+ {id: 0x02bc, ifd: '0th', name: 'ApplicationNotes', level: 'J', writable: false}, // XMP (Adobe)
76
+ {id: 0x4746, ifd: '0th', name: 'Rating', level: 'O', writable: false}, // Microsoft
77
+ {id: 0x4749, ifd: '0th', name: 'RatingPercent', level: 'O', writable: false}, // Microsoft
78
+ {id: 0x8298, ifd: '0th', name: 'Copyright', type: 'ASCII', count: 'any', level: 'O'},
79
+ {id: 0x830e, ifd: '0th', name: 'PixelScale', level: 'O', writable: false}, // GeoTIFF
80
+ {id: 0x83bb, ifd: '0th', name: 'IPTC-NAA', level: 'J', writable: false}, // IPTC
81
+ {id: 0x8480, ifd: '0th', name: 'IntergraphMatrix', level: 'O', writable: false}, // vendor
82
+ {id: 0x8482, ifd: '0th', name: 'ModelTiePoint', level: 'O', writable: false}, // GeoTIFF
83
+ {id: 0x8546, ifd: '0th', name: 'SEMInfo', level: 'O', writable: false}, // vendor
84
+ {id: 0x85d8, ifd: '0th', name: 'ModelTransform', level: 'O', writable: false}, // GeoTIFF
85
+ {id: 0x8649, ifd: '0th', name: 'PhotoshopSettings', level: 'J', writable: false}, // Photoshop
86
+ {id: 0x8769, ifd: '0th', name: 'Exif IFD Pointer', type: 'LONG', count: 1, level: 'M', thumbnailLevel: 'O', default: DEFAULT_COMPUTED},
87
+ {id: 0x8773, ifd: '0th', name: 'ICC_Profile', level: 'J', writable: false}, // ICC
88
+ {id: 0x87af, ifd: '0th', name: 'GeoTiffDirectory', level: 'O', writable: false}, // GeoTIFF
89
+ {id: 0x87b0, ifd: '0th', name: 'GeoTiffDoubleParams', level: 'O', writable: false}, // GeoTIFF
90
+ {id: 0x87b1, ifd: '0th', name: 'GeoTiffAsciiParams', level: 'O', writable: false}, // GeoTIFF
91
+ {id: 0x8825, ifd: '0th', name: 'GPS Info IFD Pointer', type: 'LONG', count: 1, level: 'O'},
92
+ {id: 0x9c9b, ifd: '0th', name: 'XPTitle', level: 'O', writable: false}, // Microsoft
93
+ {id: 0x9c9c, ifd: '0th', name: 'XPComment', level: 'O', writable: false}, // Microsoft
94
+ {id: 0x9c9d, ifd: '0th', name: 'XPAuthor', level: 'O', writable: false}, // Microsoft
95
+ {id: 0x9c9e, ifd: '0th', name: 'XPKeywords', level: 'O', writable: false}, // Microsoft
96
+ {id: 0x9c9f, ifd: '0th', name: 'XPSubject', level: 'O', writable: false}, // Microsoft
97
+ {id: 0xa480, ifd: '0th', name: 'GDALMetadata', level: 'O', writable: false}, // GDAL
98
+ {id: 0xa481, ifd: '0th', name: 'GDALNoData', level: 'O', writable: false}, // GDAL
99
+ {id: 0xc4a5, ifd: '0th', name: 'PrintIM', level: 'O', writable: false}, // vendor
100
+ {id: 0xc613, ifd: '0th', name: 'DNGBackwardVersion', level: 'O', writable: false}, // DNG
101
+ {id: 0xc614, ifd: '0th', name: 'UniqueCameraModel', level: 'O', writable: false}, // DNG
102
+ {id: 0xc615, ifd: '0th', name: 'LocalizedCameraModel', level: 'O', writable: false}, // DNG
103
+ {id: 0xc621, ifd: '0th', name: 'ColorMatrix1', level: 'O', writable: false}, // DNG
104
+ {id: 0xc622, ifd: '0th', name: 'ColorMatrix2', level: 'O', writable: false}, // DNG
105
+ {id: 0xc623, ifd: '0th', name: 'CameraCalibration1', level: 'O', writable: false}, // DNG
106
+ {id: 0xc624, ifd: '0th', name: 'CameraCalibration2', level: 'O', writable: false}, // DNG
107
+ {id: 0xc625, ifd: '0th', name: 'ReductionMatrix1', level: 'O', writable: false}, // DNG
108
+ {id: 0xc626, ifd: '0th', name: 'ReductionMatrix2', level: 'O', writable: false}, // DNG
109
+ {id: 0xc627, ifd: '0th', name: 'AnalogBalance', level: 'O', writable: false}, // DNG
110
+ {id: 0xc628, ifd: '0th', name: 'AsShotNeutral', level: 'O', writable: false}, // DNG
111
+ {id: 0xc629, ifd: '0th', name: 'AsShotWhiteXY', level: 'O', writable: false}, // DNG
112
+ {id: 0xc62a, ifd: '0th', name: 'BaselineExposure', level: 'O', writable: false}, // DNG
113
+ {id: 0xc62b, ifd: '0th', name: 'BaselineNoise', level: 'O', writable: false}, // DNG
114
+ {id: 0xc62c, ifd: '0th', name: 'BaselineSharpness', level: 'O', writable: false}, // DNG
115
+ {id: 0xc62e, ifd: '0th', name: 'LinearResponseLimit', level: 'O', writable: false}, // DNG
116
+ {id: 0xc62f, ifd: '0th', name: 'CameraSerialNumber', level: 'O', writable: false}, // DNG
117
+ {id: 0xc630, ifd: '0th', name: 'DNGLensInfo', level: 'O', writable: false}, // DNG
118
+ {id: 0xc633, ifd: '0th', name: 'ShadowScale', level: 'O', writable: false}, // DNG
119
+ {id: 0xc635, ifd: '0th', name: 'MakerNoteSafety', level: 'O', writable: false}, // DNG
120
+ {id: 0xc65a, ifd: '0th', name: 'CalibrationIlluminant1', level: 'O', writable: false}, // DNG
121
+ {id: 0xc65b, ifd: '0th', name: 'CalibrationIlluminant2', level: 'O', writable: false}, // DNG
122
+ {id: 0xc65d, ifd: '0th', name: 'RawDataUniqueID', level: 'O', writable: false}, // DNG
123
+ {id: 0xc68b, ifd: '0th', name: 'OriginalRawFileName', level: 'O', writable: false}, // DNG
124
+ {id: 0xc68c, ifd: '0th', name: 'OriginalRawFileData', level: 'O', writable: false}, // DNG
125
+ {id: 0xc68f, ifd: '0th', name: 'AsShotICCProfile', level: 'O', writable: false}, // DNG
126
+ {id: 0xc690, ifd: '0th', name: 'AsShotPreProfileMatrix', level: 'O', writable: false}, // DNG
127
+ {id: 0xc691, ifd: '0th', name: 'CurrentICCProfile', level: 'O', writable: false}, // DNG
128
+ {id: 0xc692, ifd: '0th', name: 'CurrentPreProfileMatrix', level: 'O', writable: false}, // DNG
129
+ {id: 0xc6bf, ifd: '0th', name: 'ColorimetricReference', level: 'O', writable: false}, // DNG
130
+ {id: 0xc6c5, ifd: '0th', name: 'SRawType', level: 'O', writable: false}, // vendor
131
+ {id: 0xc6d2, ifd: '0th', name: 'PanasonicTitle', level: 'O', writable: false}, // vendor
132
+ {id: 0xc6d3, ifd: '0th', name: 'PanasonicTitle2', level: 'O', writable: false}, // vendor
133
+ {id: 0xc6f3, ifd: '0th', name: 'CameraCalibrationSig', level: 'O', writable: false}, // DNG
134
+ {id: 0xc6f4, ifd: '0th', name: 'ProfileCalibrationSig', level: 'O', writable: false}, // DNG
135
+ {id: 0xc6f5, ifd: '0th', name: 'ProfileIFD', level: 'N', writable: false}, // DNG
136
+ {id: 0xc6f6, ifd: '0th', name: 'AsShotProfileName', level: 'O', writable: false}, // DNG
137
+ {id: 0xc6f8, ifd: '0th', name: 'ProfileName', level: 'O', writable: false}, // DNG
138
+ {id: 0xc6f9, ifd: '0th', name: 'ProfileHueSatMapDims', level: 'O', writable: false}, // DNG
139
+ {id: 0xc6fa, ifd: '0th', name: 'ProfileHueSatMapData1', level: 'O', writable: false}, // DNG
140
+ {id: 0xc6fb, ifd: '0th', name: 'ProfileHueSatMapData2', level: 'O', writable: false}, // DNG
141
+ {id: 0xc6fc, ifd: '0th', name: 'ProfileToneCurve', level: 'O', writable: false}, // DNG
142
+ {id: 0xc6fd, ifd: '0th', name: 'ProfileEmbedPolicy', level: 'O', writable: false}, // DNG
143
+ {id: 0xc6fe, ifd: '0th', name: 'ProfileCopyright', level: 'O', writable: false}, // DNG
144
+ {id: 0xc714, ifd: '0th', name: 'ForwardMatrix1', level: 'O', writable: false}, // DNG
145
+ {id: 0xc715, ifd: '0th', name: 'ForwardMatrix2', level: 'O', writable: false}, // DNG
146
+ {id: 0xc716, ifd: '0th', name: 'PreviewApplicationName', level: 'O', writable: false}, // DNG
147
+ {id: 0xc717, ifd: '0th', name: 'PreviewApplicationVersion', level: 'O', writable: false}, // DNG
148
+ {id: 0xc718, ifd: '0th', name: 'PreviewSettingsName', level: 'O', writable: false}, // DNG
149
+ {id: 0xc719, ifd: '0th', name: 'PreviewSettingsDigest', level: 'O', writable: false}, // DNG
150
+ {id: 0xc71a, ifd: '0th', name: 'PreviewColorSpace', level: 'O', writable: false}, // DNG
151
+ {id: 0xc71b, ifd: '0th', name: 'PreviewDateTime', level: 'O', writable: false}, // DNG
152
+ {id: 0xc71c, ifd: '0th', name: 'RawImageDigest', level: 'O', writable: false}, // DNG
153
+ {id: 0xc71d, ifd: '0th', name: 'OriginalRawFileDigest', level: 'O', writable: false}, // DNG
154
+ {id: 0xc725, ifd: '0th', name: 'ProfileLookTableDims', level: 'O', writable: false}, // DNG
155
+ {id: 0xc726, ifd: '0th', name: 'ProfileLookTableData', level: 'O', writable: false}, // DNG
156
+ {id: 0xc763, ifd: '0th', name: 'TimeCodes', level: 'O', writable: false}, // DNG
157
+ {id: 0xc764, ifd: '0th', name: 'FrameRate', level: 'O', writable: false}, // DNG
158
+ {id: 0xc772, ifd: '0th', name: 'TStop', level: 'O', writable: false}, // DNG
159
+ {id: 0xc789, ifd: '0th', name: 'ReelName', level: 'O', writable: false}, // DNG
160
+ {id: 0xc791, ifd: '0th', name: 'OriginalDefaultFinalSize', level: 'O', writable: false}, // DNG
161
+ {id: 0xc792, ifd: '0th', name: 'OriginalBestQualitySize', level: 'O', writable: false}, // DNG
162
+ {id: 0xc793, ifd: '0th', name: 'OriginalDefaultCropSize', level: 'O', writable: false}, // DNG
163
+ {id: 0xc7a1, ifd: '0th', name: 'CameraLabel', level: 'O', writable: false}, // DNG
164
+ {id: 0xc7a3, ifd: '0th', name: 'ProfileHueSatMapEncoding', level: 'O', writable: false}, // DNG
165
+ {id: 0xc7a4, ifd: '0th', name: 'ProfileLookTableEncoding', level: 'O', writable: false}, // DNG
166
+ {id: 0xc7a5, ifd: '0th', name: 'BaselineExposureOffset', level: 'O', writable: false}, // DNG
167
+ {id: 0xc7a6, ifd: '0th', name: 'DefaultBlackRender', level: 'O', writable: false}, // DNG
168
+ {id: 0xc7a7, ifd: '0th', name: 'NewRawImageDigest', level: 'O', writable: false}, // DNG
169
+ {id: 0xc7a8, ifd: '0th', name: 'RawToPreviewGain', level: 'O', writable: false}, // DNG
170
+
171
+ {id: 0x829a, ifd: 'exif', name: 'ExposureTime', type: 'RATIONAL', count: 1, level: 'R'},
172
+ {id: 0x829d, ifd: 'exif', name: 'FNumber', type: 'RATIONAL', count: 1, level: 'O'},
173
+ {id: 0x8822, ifd: 'exif', name: 'ExposureProgram', type: 'SHORT', count: 1, level: 'O'},
174
+ {id: 0x8824, ifd: 'exif', name: 'SpectralSensitivity', type: 'ASCII', count: 'any', level: 'O'},
175
+ {id: 0x8827, ifd: 'exif', name: 'ISOSpeedRatings', type: 'SHORT', count: 'any', level: 'O'},
176
+ {id: 0x8828, ifd: 'exif', name: 'OECF', type: 'UNDEFINED', count: 'any', level: 'O'},
177
+ {id: 0x882a, ifd: 'exif', name: 'TimeZoneOffset', level: 'O', writable: false}, // TIFF/EP
178
+ {id: 0x882b, ifd: 'exif', name: 'SelfTimerMode', level: 'O', writable: false}, // TIFF/EP
179
+ {id: 0x8830, ifd: 'exif', name: 'SensitivityType', type: 'SHORT', count: 1, level: 'O'},
180
+ {id: 0x8831, ifd: 'exif', name: 'StandardOutputSensitivity', type: 'LONG', count: 1, level: 'O'},
181
+ {id: 0x8832, ifd: 'exif', name: 'RecommendedExposureIndex', type: 'LONG', count: 1, level: 'O'},
182
+ {id: 0x8833, ifd: 'exif', name: 'ISOSpeed', type: 'LONG', count: 1, level: 'O'},
183
+ {id: 0x8834, ifd: 'exif', name: 'ISOSpeedLatitudeyyy', type: 'LONG', count: 1, level: 'O'},
184
+ {id: 0x8835, ifd: 'exif', name: 'ISOSpeedLatitudezzz', type: 'LONG', count: 1, level: 'O'},
185
+ {id: 0x9000, ifd: 'exif', name: 'ExifVersion', type: 'UNDEFINED', count: 4, level: 'M', default: [0x30, 0x32, 0x33, 0x32]},
186
+ {id: 0x9003, ifd: 'exif', name: 'DateTimeOriginal', type: 'ASCII', count: 20, level: 'O'},
187
+ {id: 0x9004, ifd: 'exif', name: 'DateTimeDigitized', type: 'ASCII', count: 20, level: 'O'},
188
+ {id: 0x9009, ifd: 'exif', name: 'GooglePlusUploadCode', level: 'O', writable: false}, // vendor
189
+ {id: 0x9010, ifd: 'exif', name: 'OffsetTime', type: 'ASCII', count: 7, level: 'O'},
190
+ {id: 0x9011, ifd: 'exif', name: 'OffsetTimeOriginal', type: 'ASCII', count: 7, level: 'O'},
191
+ {id: 0x9012, ifd: 'exif', name: 'OffsetTimeDigitized', type: 'ASCII', count: 7, level: 'O'},
192
+ {id: 0x9101, ifd: 'exif', name: 'ComponentsConfiguration', type: 'UNDEFINED', count: 4, level: 'M', default: [1, 2, 3, 0]},
193
+ {id: 0x9102, ifd: 'exif', name: 'CompressedBitsPerPixel', type: 'RATIONAL', count: 1, level: 'O'},
194
+ {id: 0x9201, ifd: 'exif', name: 'ShutterSpeedValue', type: 'SRATIONAL', count: 1, level: 'O'},
195
+ {id: 0x9202, ifd: 'exif', name: 'ApertureValue', type: 'RATIONAL', count: 1, level: 'O'},
196
+ {id: 0x9203, ifd: 'exif', name: 'BrightnessValue', type: 'SRATIONAL', count: 1, level: 'O'},
197
+ {id: 0x9204, ifd: 'exif', name: 'ExposureBiasValue', type: 'SRATIONAL', count: 1, level: 'O'},
198
+ {id: 0x9205, ifd: 'exif', name: 'MaxApertureValue', type: 'RATIONAL', count: 1, level: 'O'},
199
+ {id: 0x9206, ifd: 'exif', name: 'SubjectDistance', type: 'RATIONAL', count: 1, level: 'O'},
200
+ {id: 0x9207, ifd: 'exif', name: 'MeteringMode', type: 'SHORT', count: 1, level: 'O'},
201
+ {id: 0x9208, ifd: 'exif', name: 'LightSource', type: 'SHORT', count: 1, level: 'O'},
202
+ {id: 0x9209, ifd: 'exif', name: 'Flash', type: 'SHORT', count: 1, level: 'R'},
203
+ {id: 0x920a, ifd: 'exif', name: 'FocalLength', type: 'RATIONAL', count: 1, level: 'O'},
204
+ {id: 0x9211, ifd: 'exif', name: 'ImageNumber', level: 'O', writable: false}, // TIFF/EP
205
+ {id: 0x9212, ifd: 'exif', name: 'SecurityClassification', level: 'O', writable: false}, // TIFF/EP
206
+ {id: 0x9213, ifd: 'exif', name: 'ImageHistory', level: 'O', writable: false}, // TIFF/EP
207
+ {id: 0x9214, ifd: 'exif', name: 'SubjectArea', type: 'SHORT', count: 'any', level: 'O'}, // DC-008 count: 2 or 3 or 4
208
+ {id: 0x927c, ifd: 'exif', name: 'MakerNote', type: 'UNDEFINED', count: 'any', level: 'O'},
209
+ {id: 0x9286, ifd: 'exif', name: 'UserComment', type: 'UNDEFINED', count: 'any', level: 'O'},
210
+ {id: 0x9290, ifd: 'exif', name: 'SubSecTime', type: 'ASCII', count: 'any', level: 'O'},
211
+ {id: 0x9291, ifd: 'exif', name: 'SubSecTimeOriginal', type: 'ASCII', count: 'any', level: 'O'},
212
+ {id: 0x9292, ifd: 'exif', name: 'SubSecTimeDigitized', type: 'ASCII', count: 'any', level: 'O'},
213
+ {id: 0x935c, ifd: 'exif', name: 'ImageSourceData', level: 'O', writable: false}, // Photoshop
214
+ {id: 0x9400, ifd: 'exif', name: 'AmbientTemperature', type: 'SRATIONAL', count: 1, level: 'O'},
215
+ {id: 0x9401, ifd: 'exif', name: 'Humidity', type: 'RATIONAL', count: 1, level: 'O'},
216
+ {id: 0x9402, ifd: 'exif', name: 'Pressure', type: 'RATIONAL', count: 1, level: 'O'},
217
+ {id: 0x9403, ifd: 'exif', name: 'WaterDepth', type: 'SRATIONAL', count: 1, level: 'O'},
218
+ {id: 0x9404, ifd: 'exif', name: 'Acceleration', type: 'RATIONAL', count: 1, level: 'O'},
219
+ {id: 0x9405, ifd: 'exif', name: 'CameraElevationAngle', type: 'SRATIONAL', count: 1, level: 'O'},
220
+ {id: 0xa000, ifd: 'exif', name: 'FlashpixVersion', type: 'UNDEFINED', count: 4, level: 'M', default: [0x30, 0x31, 0x30, 0x30]},
221
+ {id: 0xa001, ifd: 'exif', name: 'ColorSpace', type: 'SHORT', count: 1, level: 'M', default: 0xffff},
222
+ {id: 0xa002, ifd: 'exif', name: 'PixelXDimension', type: ['SHORT', 'LONG'], count: 1, level: 'M', default: DEFAULT_FROM_SOF},
223
+ {id: 0xa003, ifd: 'exif', name: 'PixelYDimension', type: ['SHORT', 'LONG'], count: 1, level: 'M', default: DEFAULT_FROM_SOF},
224
+ {id: 0xa004, ifd: 'exif', name: 'RelatedSoundFile', type: 'ASCII', count: 13, level: 'O'},
225
+ {id: 0xa005, ifd: 'exif', name: 'Interoperability IFD Pointer', type: 'LONG', count: 1, level: 'O'},
226
+ {id: 0xa20b, ifd: 'exif', name: 'FlashEnergy', type: 'RATIONAL', count: 1, level: 'O'},
227
+ {id: 0xa20c, ifd: 'exif', name: 'SpatialFrequencyResponse', type: 'UNDEFINED', count: 'any', level: 'O'},
228
+ {id: 0xa20e, ifd: 'exif', name: 'FocalPlaneXResolution', type: 'RATIONAL', count: 1, level: 'O'},
229
+ {id: 0xa20f, ifd: 'exif', name: 'FocalPlaneYResolution', type: 'RATIONAL', count: 1, level: 'O'},
230
+ {id: 0xa210, ifd: 'exif', name: 'FocalPlaneResolutionUnit', type: 'SHORT', count: 1, level: 'O'},
231
+ {id: 0xa214, ifd: 'exif', name: 'SubjectLocation', type: 'SHORT', count: 2, level: 'O'},
232
+ {id: 0xa215, ifd: 'exif', name: 'ExposureIndex', type: 'RATIONAL', count: 1, level: 'O'},
233
+ {id: 0xa217, ifd: 'exif', name: 'SensingMethod', type: 'SHORT', count: 1, level: 'O'},
234
+ {id: 0xa300, ifd: 'exif', name: 'FileSource', type: 'UNDEFINED', count: 1, level: 'O'},
235
+ {id: 0xa301, ifd: 'exif', name: 'SceneType', type: 'UNDEFINED', count: 1, level: 'O'},
236
+ {id: 0xa302, ifd: 'exif', name: 'CFAPattern', type: 'UNDEFINED', count: 'any', level: 'O'},
237
+ {id: 0xa401, ifd: 'exif', name: 'CustomRendered', type: 'SHORT', count: 1, level: 'O'},
238
+ {id: 0xa402, ifd: 'exif', name: 'ExposureMode', type: 'SHORT', count: 1, level: 'R'},
239
+ {id: 0xa403, ifd: 'exif', name: 'WhiteBalance', type: 'SHORT', count: 1, level: 'R'},
240
+ {id: 0xa404, ifd: 'exif', name: 'DigitalZoomRatio', type: 'RATIONAL', count: 1, level: 'O'},
241
+ {id: 0xa405, ifd: 'exif', name: 'FocalLengthIn35mmFilm', type: 'SHORT', count: 1, level: 'O'},
242
+ {id: 0xa406, ifd: 'exif', name: 'SceneCaptureType', type: 'SHORT', count: 1, level: 'R'},
243
+ {id: 0xa407, ifd: 'exif', name: 'GainControl', type: 'SHORT', count: 1, level: 'O'}, // Table 8 says RATIONAL, the definition SHORT
244
+ {id: 0xa408, ifd: 'exif', name: 'Contrast', type: 'SHORT', count: 1, level: 'O'},
245
+ {id: 0xa409, ifd: 'exif', name: 'Saturation', type: 'SHORT', count: 1, level: 'O'},
246
+ {id: 0xa40a, ifd: 'exif', name: 'Sharpness', type: 'SHORT', count: 1, level: 'O'},
247
+ {id: 0xa40b, ifd: 'exif', name: 'DeviceSettingDescription', type: 'UNDEFINED', count: 'any', level: 'O'},
248
+ {id: 0xa40c, ifd: 'exif', name: 'SubjectDistanceRange', type: 'SHORT', count: 1, level: 'O'},
249
+ {id: 0xa420, ifd: 'exif', name: 'ImageUniqueID', type: 'ASCII', count: 33, level: 'O'},
250
+ {id: 0xa430, ifd: 'exif', name: 'CameraOwnerName', type: 'ASCII', count: 'any', level: 'O'},
251
+ {id: 0xa431, ifd: 'exif', name: 'BodySerialNumber', type: 'ASCII', count: 'any', level: 'O'},
252
+ {id: 0xa432, ifd: 'exif', name: 'LensSpecification', type: 'RATIONAL', count: 4, level: 'O'},
253
+ {id: 0xa433, ifd: 'exif', name: 'LensMake', type: 'ASCII', count: 'any', level: 'O'},
254
+ {id: 0xa434, ifd: 'exif', name: 'LensModel', type: 'ASCII', count: 'any', level: 'O'},
255
+ {id: 0xa435, ifd: 'exif', name: 'LensSerialNumber', type: 'ASCII', count: 'any', level: 'O'},
256
+ {id: 0xa460, ifd: 'exif', name: 'CompositeImage', type: 'SHORT', count: 1, level: 'R'},
257
+ {id: 0xa461, ifd: 'exif', name: 'SourceImageNumberOfCompositeImage', type: 'SHORT', count: 2, level: 'O'},
258
+ {id: 0xa462, ifd: 'exif', name: 'SourceExposureTimesOfCompositeImage', type: 'UNDEFINED', count: 'any', level: 'O'},
259
+ {id: 0xa500, ifd: 'exif', name: 'Gamma', type: 'RATIONAL', count: 1, level: 'O'},
260
+ {id: 0xea1c, ifd: 'exif', name: 'Padding', level: 'O', writable: false}, // Microsoft
261
+ {id: 0xea1d, ifd: 'exif', name: 'OffsetSchema', level: 'O', writable: false}, // Microsoft
262
+ {id: 0xfde8, ifd: 'exif', name: 'OwnerName', level: 'O', writable: false}, // Adobe
263
+ {id: 0xfde9, ifd: 'exif', name: 'SerialNumber', level: 'O', writable: false}, // Adobe
264
+ {id: 0xfdea, ifd: 'exif', name: 'Lens', level: 'O', writable: false}, // Adobe
265
+ {id: 0xfe4c, ifd: 'exif', name: 'RawFile', level: 'O', writable: false}, // Adobe
266
+ {id: 0xfe4d, ifd: 'exif', name: 'Converter', level: 'O', writable: false}, // Adobe
267
+ {id: 0xfe4e, ifd: 'exif', name: 'WhiteBalance', level: 'O', writable: false}, // Adobe
268
+ {id: 0xfe51, ifd: 'exif', name: 'Exposure', level: 'O', writable: false}, // Adobe
269
+ {id: 0xfe52, ifd: 'exif', name: 'Shadows', level: 'O', writable: false}, // Adobe
270
+ {id: 0xfe53, ifd: 'exif', name: 'Brightness', level: 'O', writable: false}, // Adobe
271
+ {id: 0xfe54, ifd: 'exif', name: 'Contrast', level: 'O', writable: false}, // Adobe
272
+ {id: 0xfe55, ifd: 'exif', name: 'Saturation', level: 'O', writable: false}, // Adobe
273
+ {id: 0xfe56, ifd: 'exif', name: 'Sharpness', level: 'O', writable: false}, // Adobe
274
+ {id: 0xfe57, ifd: 'exif', name: 'Smoothness', level: 'O', writable: false}, // Adobe
275
+ {id: 0xfe58, ifd: 'exif', name: 'MoireFilter', level: 'O', writable: false}, // Adobe
276
+
277
+ {id: 0x0000, ifd: 'gps', name: 'GPSVersionID', type: 'BYTE', count: 4, level: 'M', default: [2, 3, 0, 0]}, // Table 19 says O; §4.6.6 makes it mandatory in a GPS IFD
278
+ {id: 0x0001, ifd: 'gps', name: 'GPSLatitudeRef', type: 'ASCII', count: 2, level: 'O'},
279
+ {id: 0x0002, ifd: 'gps', name: 'GPSLatitude', type: 'RATIONAL', count: 3, level: 'O'},
280
+ {id: 0x0003, ifd: 'gps', name: 'GPSLongitudeRef', type: 'ASCII', count: 2, level: 'O'},
281
+ {id: 0x0004, ifd: 'gps', name: 'GPSLongitude', type: 'RATIONAL', count: 3, level: 'O'},
282
+ {id: 0x0005, ifd: 'gps', name: 'GPSAltitudeRef', type: 'BYTE', count: 1, level: 'O'},
283
+ {id: 0x0006, ifd: 'gps', name: 'GPSAltitude', type: 'RATIONAL', count: 1, level: 'O'},
284
+ {id: 0x0007, ifd: 'gps', name: 'GPSTimeStamp', type: 'RATIONAL', count: 3, level: 'O'},
285
+ {id: 0x0008, ifd: 'gps', name: 'GPSSatellites', type: 'ASCII', count: 'any', level: 'O'},
286
+ {id: 0x0009, ifd: 'gps', name: 'GPSStatus', type: 'ASCII', count: 2, level: 'O'},
287
+ {id: 0x000a, ifd: 'gps', name: 'GPSMeasureMode', type: 'ASCII', count: 2, level: 'O'},
288
+ {id: 0x000b, ifd: 'gps', name: 'GPSDOP', type: 'RATIONAL', count: 1, level: 'O'},
289
+ {id: 0x000c, ifd: 'gps', name: 'GPSSpeedRef', type: 'ASCII', count: 2, level: 'O'},
290
+ {id: 0x000d, ifd: 'gps', name: 'GPSSpeed', type: 'RATIONAL', count: 1, level: 'O'},
291
+ {id: 0x000e, ifd: 'gps', name: 'GPSTrackRef', type: 'ASCII', count: 2, level: 'O'},
292
+ {id: 0x000f, ifd: 'gps', name: 'GPSTrack', type: 'RATIONAL', count: 1, level: 'O'},
293
+ {id: 0x0010, ifd: 'gps', name: 'GPSImgDirectionRef', type: 'ASCII', count: 2, level: 'O'},
294
+ {id: 0x0011, ifd: 'gps', name: 'GPSImgDirection', type: 'RATIONAL', count: 1, level: 'O'},
295
+ {id: 0x0012, ifd: 'gps', name: 'GPSMapDatum', type: 'ASCII', count: 'any', level: 'O'},
296
+ {id: 0x0013, ifd: 'gps', name: 'GPSDestLatitudeRef', type: 'ASCII', count: 2, level: 'O'},
297
+ {id: 0x0014, ifd: 'gps', name: 'GPSDestLatitude', type: 'RATIONAL', count: 3, level: 'O'},
298
+ {id: 0x0015, ifd: 'gps', name: 'GPSDestLongitudeRef', type: 'ASCII', count: 2, level: 'O'},
299
+ {id: 0x0016, ifd: 'gps', name: 'GPSDestLongitude', type: 'RATIONAL', count: 3, level: 'O'},
300
+ {id: 0x0017, ifd: 'gps', name: 'GPSDestBearingRef', type: 'ASCII', count: 2, level: 'O'},
301
+ {id: 0x0018, ifd: 'gps', name: 'GPSDestBearing', type: 'RATIONAL', count: 1, level: 'O'},
302
+ {id: 0x0019, ifd: 'gps', name: 'GPSDestDistanceRef', type: 'ASCII', count: 2, level: 'O'},
303
+ {id: 0x001a, ifd: 'gps', name: 'GPSDestDistance', type: 'RATIONAL', count: 1, level: 'O'},
304
+ {id: 0x001b, ifd: 'gps', name: 'GPSProcessingMethod', type: 'UNDEFINED', count: 'any', level: 'O'},
305
+ {id: 0x001c, ifd: 'gps', name: 'GPSAreaInformation', type: 'UNDEFINED', count: 'any', level: 'O'},
306
+ {id: 0x001d, ifd: 'gps', name: 'GPSDateStamp', type: 'ASCII', count: 11, level: 'O'},
307
+ {id: 0x001e, ifd: 'gps', name: 'GPSDifferential', type: 'SHORT', count: 1, level: 'O'},
308
+ {id: 0x001f, ifd: 'gps', name: 'GPSHPositioningError', type: 'RATIONAL', count: 1, level: 'O'},
309
+
310
+ {id: 0x0001, ifd: 'interoperability', name: 'InteroperabilityIndex', type: 'ASCII', count: 'any', level: 'O'},
311
+ {id: 0x0002, ifd: 'interoperability', name: 'InteroperabilityVersion', level: 'O', writable: false}, // Exif R98
312
+ {id: 0x1000, ifd: 'interoperability', name: 'RelatedImageFileFormat', level: 'O', writable: false}, // Exif R98
313
+ {id: 0x1001, ifd: 'interoperability', name: 'RelatedImageWidth', level: 'O', writable: false}, // Exif R98
314
+ {id: 0x1002, ifd: 'interoperability', name: 'RelatedImageHeight', level: 'O', writable: false} // Exif R98
315
+ ];
316
+
317
+ export default {
318
+ tags,
319
+ DEFAULT_FROM_SOF,
320
+ DEFAULT_COMPUTED
321
+ };
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, pushMetadataBlock} from './utils.js';
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
- * Finds the XMP chunk offset for a standalone XMP file.
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 offsets in.
36
- * @param {Array<Object>=} metadataBlocks Optional out-array. When provided,
37
- * receives one `xmp` block covering the whole buffer and gets a
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 {{xmpChunks: Array<{dataOffset: number, length: number}>}}
39
+ * @returns {Array<Object>} One xmp block with one chunk.
40
40
  */
41
- function findOffsets(dataView, metadataBlocks) {
42
- const xmpChunks = [];
43
- xmpChunks.push({dataOffset: XML_MARKER_OFFSET, length: dataView.byteLength});
44
- pushMetadataBlock(metadataBlocks, 'xmp', 0, dataView.byteLength);
45
- if (metadataBlocks) {
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) {
@@ -10,16 +10,19 @@ const NAME_END_CHARACTERS = ' \t\r\n/><="\'';
10
10
  /**
11
11
  * Tells whether an XML string has elements nested deeper than a bound or more
12
12
  * markup nodes than a bound, in linear time. The nodes are elements, attributes
13
- * (namespace declarations included), comments, processing instructions, CDATA
14
- * sections and <! declarations together; text is not counted. Malformed markup
15
- * may be counted deeper and with more nodes than @xmldom/xmldom 0.9.12 builds,
16
- * never shallower or with fewer.
13
+ * (namespace declarations included), comments, processing instructions and
14
+ * CDATA sections together; text is not counted. Malformed markup may be counted
15
+ * deeper and with more nodes than @xmldom/xmldom 0.9.12 builds, never shallower
16
+ * or with fewer. A markup declaration such as a DOCTYPE also makes it true,
17
+ * unless it is in a comment, a CDATA section or an end tag, and so does one in a
18
+ * processing instruction: a parser may expand an entity declared there into
19
+ * markup the scan cannot count.
17
20
  *
18
21
  * @param {string} xmlString
19
22
  * @param {number} maxDepth The deepest allowed element, the root being 1.
20
23
  * @param {number} [maxNodes] The most markup nodes allowed.
21
- * @returns {boolean} True as soon as an element is nested deeper than maxDepth
22
- * or the markup nodes are more than maxNodes.
24
+ * @returns {boolean} True as soon as an element is nested deeper than maxDepth,
25
+ * the markup nodes are more than maxNodes, or a markup declaration is found.
23
26
  */
24
27
  export function exceedsMarkupBounds(xmlString, maxDepth, maxNodes = Infinity) {
25
28
  let depth = 0;
@@ -33,11 +36,15 @@ export function exceedsMarkupBounds(xmlString, maxDepth, maxNodes = Infinity) {
33
36
  nodeCount++;
34
37
  index = skipPast(xmlString, index + 9, ']]>');
35
38
  } else if (hasSubstringAt(xmlString, '<?', index)) {
39
+ const endIndex = skipPast(xmlString, index + 2, '?>');
40
+ // A parser that recovers from errors may end the instruction early.
41
+ if (xmlString.slice(index + 2, endIndex).indexOf('<!') !== -1) {
42
+ return true;
43
+ }
36
44
  nodeCount++;
37
- index = skipPast(xmlString, index + 2, '?>');
45
+ index = endIndex;
38
46
  } else if (hasSubstringAt(xmlString, '<!', index)) {
39
- nodeCount++;
40
- index = skipDeclaration(xmlString, index + 2);
47
+ return true;
41
48
  } else if (hasSubstringAt(xmlString, '</', index)) {
42
49
  depth = Math.max(depth - 1, 0);
43
50
  // xmldom ends an end tag at its first >, whatever comes between.
@@ -62,23 +69,6 @@ export function exceedsMarkupBounds(xmlString, maxDepth, maxNodes = Infinity) {
62
69
  return false;
63
70
  }
64
71
 
65
- // Stopping at [ lets the main loop read the declarations of a DOCTYPE internal
66
- // subset one by one.
67
- function skipDeclaration(xmlString, fromIndex) {
68
- for (let index = fromIndex; index < xmlString.length; index++) {
69
- const character = xmlString.charAt(index);
70
- if (character === '"' || character === '\'') {
71
- index = xmlString.indexOf(character, index + 1);
72
- if (index === -1) {
73
- return xmlString.length;
74
- }
75
- } else if (character === '>' || character === '[') {
76
- return index + 1;
77
- }
78
- }
79
- return xmlString.length;
80
- }
81
-
82
72
  // A start tag cannot hold a <, so every search in it stops at the next <, which
83
73
  // keeps the scan linear. Only a well-formed tag is read as self-closing: some
84
74
  // parsers keep a malformed one open, so reading it as open can only count deeper.
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,10 +137,10 @@ function readTags(tags, chunkDataView, domParser) {
138
137
  }
139
138
  }
140
139
 
141
- function getDocument(chunkDataView, _domParser) {
142
- const domParser = DOMParser.get(_domParser);
140
+ function getDocument(chunkDataView, _domParser, getDomParser) {
141
+ const {parser: domParser, warning} = getDomParser(_domParser);
143
142
  if (!domParser) {
144
- console.warn('Warning: DOMParser is not available. It is needed to be able to parse XMP tags.'); // eslint-disable-line no-console
143
+ console.warn(warning); // eslint-disable-line no-console
145
144
  throw new Error();
146
145
  }
147
146
 
@@ -219,7 +218,7 @@ function trimAfterPacketTrailer(xmlSource) {
219
218
 
220
219
  function parseFromString(domParser, xmlString, isRetry = false) {
221
220
  if (exceedsMarkupBounds(xmlString, MAX_ELEMENT_DEPTH, MAX_MARKUP_NODES)) {
222
- throw new ParseError(`XMP elements nested deeper than ${MAX_ELEMENT_DEPTH} levels or more than ${MAX_MARKUP_NODES} markup nodes.`);
221
+ throw new ParseError(`XMP has elements nested deeper than ${MAX_ELEMENT_DEPTH} levels, more than ${MAX_MARKUP_NODES} markup nodes, or a markup declaration.`);
223
222
  }
224
223
  try {
225
224
  const doc = domParser.parseFromString(xmlString, 'application/xml');