exifreader 4.37.1 → 4.38.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 +77 -19
- package/dist/exif-reader.js +1 -1
- package/dist/exif-reader.js.map +1 -1
- package/exif-reader.d.ts +10 -0
- package/package.json +4 -3
- package/src/constants.js +1 -0
- package/src/exif-reader.js +111 -4
- package/src/icc-tags.js +4 -4
- package/src/image-header-iso-bmff.js +2 -2
- package/src/image-header-jxl.js +144 -0
- package/src/image-header.js +5 -0
- package/src/jxl-file-tags.js +74 -0
- package/src/loadview-pipeline.js +46 -0
- package/src/png-text-tags.js +5 -4
- package/src/utils.js +40 -1
- package/webpack.config.js +2 -1
package/src/utils.js
CHANGED
|
@@ -149,8 +149,29 @@ export function strRepeat(string, num) {
|
|
|
149
149
|
|
|
150
150
|
export const COMPRESSION_METHOD_NONE = undefined;
|
|
151
151
|
export const COMPRESSION_METHOD_DEFLATE = 0;
|
|
152
|
+
export const COMPRESSION_METHOD_BROTLI = 'brotli';
|
|
153
|
+
|
|
154
|
+
export function decompress(dataView, compressionMethod, encoding, returnType = 'string', decompressConfig) {
|
|
155
|
+
if (decompressConfig && compressionMethod !== COMPRESSION_METHOD_NONE) {
|
|
156
|
+
const decompressType = compressionMethod === COMPRESSION_METHOD_DEFLATE ? 'deflate' : 'brotli';
|
|
157
|
+
const customFn = decompressConfig[decompressType];
|
|
158
|
+
if (typeof customFn === 'function') {
|
|
159
|
+
const uint8 = new Uint8Array(dataView.buffer, dataView.byteOffset, dataView.byteLength);
|
|
160
|
+
return Promise.resolve(customFn(uint8)).then((result) => {
|
|
161
|
+
if (returnType === 'dataview') {
|
|
162
|
+
if (result instanceof DataView) {
|
|
163
|
+
return result;
|
|
164
|
+
}
|
|
165
|
+
if (result instanceof ArrayBuffer) {
|
|
166
|
+
return new DataView(result);
|
|
167
|
+
}
|
|
168
|
+
return new DataView(result.buffer, result.byteOffset, result.byteLength);
|
|
169
|
+
}
|
|
170
|
+
return new TextDecoder(encoding).decode(result);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
152
174
|
|
|
153
|
-
export function decompress(dataView, compressionMethod, encoding, returnType = 'string') {
|
|
154
175
|
if (compressionMethod === COMPRESSION_METHOD_DEFLATE) {
|
|
155
176
|
if (typeof DecompressionStream === 'function') {
|
|
156
177
|
const decompressionStream = new DecompressionStream('deflate');
|
|
@@ -162,6 +183,24 @@ export function decompress(dataView, compressionMethod, encoding, returnType = '
|
|
|
162
183
|
.then((buffer) => new TextDecoder(encoding).decode(buffer));
|
|
163
184
|
}
|
|
164
185
|
}
|
|
186
|
+
|
|
187
|
+
if (compressionMethod === COMPRESSION_METHOD_BROTLI) {
|
|
188
|
+
if (typeof DecompressionStream === 'function') {
|
|
189
|
+
try {
|
|
190
|
+
const decompressionStream = new DecompressionStream('brotli');
|
|
191
|
+
const decompressedStream = new Blob([dataView]).stream().pipeThrough(decompressionStream);
|
|
192
|
+
if (returnType === 'dataview') {
|
|
193
|
+
return new Response(decompressedStream).arrayBuffer().then((arrayBuffer) => new DataView(arrayBuffer));
|
|
194
|
+
}
|
|
195
|
+
return new Response(decompressedStream).arrayBuffer()
|
|
196
|
+
.then((buffer) => new TextDecoder(encoding).decode(buffer));
|
|
197
|
+
} catch (_error) {
|
|
198
|
+
// brotli not supported by this DecompressionStream implementation
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return Promise.reject('Brotli decompression is not supported in this environment. Pass in a brotli decompression function via the decompress option.');
|
|
202
|
+
}
|
|
203
|
+
|
|
165
204
|
if (compressionMethod !== undefined) {
|
|
166
205
|
return Promise.reject(`Unknown compression method ${compressionMethod}.`);
|
|
167
206
|
}
|
package/webpack.config.js
CHANGED
|
@@ -81,7 +81,7 @@ module.exports = {
|
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
{
|
|
84
|
-
test: /[/\\](exif-reader|image-header-?(tiff|jpeg|png|heic|avif|iso-bmff|webp|gif)?|tags|tag-names|tags-helpers|png-text-tags)\.js$/,
|
|
84
|
+
test: /[/\\](exif-reader|image-header-?(tiff|jpeg|png|heic|avif|jxl|iso-bmff|webp|gif)?|tags|tag-names|tags-helpers|png-text-tags)\.js$/,
|
|
85
85
|
loader: 'string-replace-loader',
|
|
86
86
|
options: {
|
|
87
87
|
multiple: getConstantReplacements(includedModules)
|
|
@@ -109,6 +109,7 @@ function parseConfig({include: includesConfig, exclude: excludesConfig}) {
|
|
|
109
109
|
'png',
|
|
110
110
|
'heic',
|
|
111
111
|
'avif',
|
|
112
|
+
'jxl',
|
|
112
113
|
'webp',
|
|
113
114
|
'gif'
|
|
114
115
|
];
|