exifreader 4.50.0 → 4.51.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 +15 -9
- package/dist/exif-reader.js +1 -1
- package/dist/exif-reader.js.map +1 -1
- package/exif-reader.d.ts +14 -10
- package/package.json +3 -3
- package/src/canon-tags.js +11 -2
- package/src/composite.js +2 -2
- package/src/exif-reader.js +91 -32
- package/src/file-loaders.js +28 -12
- package/src/icc-tags.js +1 -3
- package/src/ifd-types.js +14 -0
- package/src/image-header-iso-bmff.js +19 -30
- package/src/image-header-jpeg.js +9 -10
- package/src/image-header-jxl.js +4 -5
- package/src/image-header-png.js +3 -4
- package/src/image-header-tiff.js +4 -8
- package/src/image-header-webp.js +3 -4
- package/src/jfif-tags.js +1 -1
- package/src/load-auto.js +2 -2
- package/src/mpf-tags.js +12 -3
- package/src/pentax-tags.js +11 -2
- package/src/png-text-tags.js +22 -18
- package/src/tag-names-common.js +8 -6
- package/src/tag-names.js +27 -16
- package/src/tags-helpers.js +41 -32
- package/src/tags.js +13 -8
- package/src/thumbnail.js +1 -1
- package/src/utils.js +26 -4
- package/src/xmp-tags.js +4 -6
- package/webpack.config.js +1 -1
- package/src/dataview.js +0 -51
package/README.md
CHANGED
|
@@ -183,7 +183,8 @@ local file path and will make a network request or read from the file system.
|
|
|
183
183
|
Never pass an untrusted or user-controlled string to `load()`. Doing so lets an
|
|
184
184
|
attacker make the process fetch arbitrary URLs (server-side request forgery) or
|
|
185
185
|
open arbitrary local files. For untrusted image data, always pass the bytes
|
|
186
|
-
themselves (an `ArrayBuffer`, a
|
|
186
|
+
themselves (an `ArrayBuffer`, a typed array such as `Uint8Array` or `Buffer`, or
|
|
187
|
+
a browser `File`), never a string.
|
|
187
188
|
|
|
188
189
|
**Tip:** To read metadata from an `HTMLImageElement`, wait for its `load` event
|
|
189
190
|
and call `ExifReader.load(image.src)`. The browser should reuse the cached file.
|
|
@@ -197,6 +198,7 @@ const tags = ExifReader.load(fileBuffer);
|
|
|
197
198
|
Where `fileBuffer` is one of
|
|
198
199
|
|
|
199
200
|
* `ArrayBuffer` or `SharedArrayBuffer` (browser, Node.js)
|
|
201
|
+
* any typed array such as `Uint8Array`, or a `DataView` (browser, Node.js)
|
|
200
202
|
* `Buffer` (Node.js)
|
|
201
203
|
|
|
202
204
|
See the [examples site](https://mattiasw.github.io/ExifReader/) for more
|
|
@@ -390,8 +392,9 @@ does not fit inside the part you read, no ICC tags are returned for it. Use
|
|
|
390
392
|
yourself.
|
|
391
393
|
|
|
392
394
|
Note that this option only works when ExifReader handles the loading of the
|
|
393
|
-
file. If e.g. an already loaded ArrayBuffer or Buffer is passed
|
|
394
|
-
the whole file will already have been loaded into memory and
|
|
395
|
+
file. If e.g. an already loaded ArrayBuffer, typed array or Buffer is passed
|
|
396
|
+
into ExifReader, the whole file will already have been loaded into memory and
|
|
397
|
+
it's too late.
|
|
395
398
|
More specifically the length option will work for 1. local files when running
|
|
396
399
|
through Node.js, 2. remote files when passing a URL, and 3. browser File objects
|
|
397
400
|
(e.g., from form file fields). For remote files accessed through a web browser,
|
|
@@ -420,8 +423,11 @@ const tags = await ExifReader.load(url, {
|
|
|
420
423
|
tags.metadataRange.end // exact byte count needed for the metadata
|
|
421
424
|
tags.metadataRange.buffer // bytes [0, end), sliced from what we read.
|
|
422
425
|
// Same kind as the input (ArrayBuffer,
|
|
423
|
-
// SharedArrayBuffer or Node Buffer).
|
|
424
|
-
//
|
|
426
|
+
// SharedArrayBuffer or Node Buffer). For a
|
|
427
|
+
// typed array or DataView input it is an
|
|
428
|
+
// ArrayBuffer (a SharedArrayBuffer when the
|
|
429
|
+
// view is over one) holding only the view's
|
|
430
|
+
// bytes. Save this to disk to keep only the
|
|
425
431
|
// metadata-bearing prefix.
|
|
426
432
|
tags.metadataRange.fetched // bytes actually read. May be greater than
|
|
427
433
|
// `end` because the loop reads in fixed-size
|
|
@@ -442,10 +448,10 @@ Exif/XMP `iloc` entries point near the end of the file typically take two.
|
|
|
442
448
|
- Local file path via Node `fs`
|
|
443
449
|
- Browser `File` object via `File.slice`
|
|
444
450
|
|
|
445
|
-
It is also accepted for in-memory inputs (`ArrayBuffer`, `SharedArrayBuffer
|
|
446
|
-
|
|
447
|
-
case, but `metadataRange.buffer` is still attached
|
|
448
|
-
what you passed in.
|
|
451
|
+
It is also accepted for in-memory inputs (`ArrayBuffer`, `SharedArrayBuffer`,
|
|
452
|
+
Node.js `Buffer`, any other typed array and `DataView`) as a convenience. There
|
|
453
|
+
is no IO loop to run in that case, but `metadataRange.buffer` is still attached
|
|
454
|
+
as the trimmed slice of what you passed in.
|
|
449
455
|
|
|
450
456
|
Requirements and caveats:
|
|
451
457
|
|