exifreader 4.48.0 → 4.49.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 +66 -46
- package/dist/exif-reader.js +1 -1
- package/dist/exif-reader.js.map +1 -1
- package/exif-reader.d.ts +6 -6
- package/package.json +5 -5
- package/src/canon-tags.js +4 -3
- package/src/exif-reader.js +247 -166
- package/src/icc-tag-names.js +2 -11
- package/src/image-header-iso-bmff.js +261 -39
- package/src/image-header-jxl.js +6 -6
- package/src/image-header-png.js +1 -6
- package/src/iptc-tag-names.js +35 -17
- package/src/iso-bmff-file-tags.js +86 -0
- package/src/loadview-pipeline.js +106 -28
- package/src/photoshop-tags.js +9 -1
- package/src/png-text-tags.js +94 -52
- package/src/tag-decoder.js +3 -3
- package/src/tag-filter-config.js +23 -0
- package/src/tag-names-0th-ifd.js +51 -42
- package/src/tag-names-common.js +19 -15
- package/src/tag-names-exif-ifd.js +38 -17
- package/src/tag-names-interoperability-ifd.js +2 -2
- package/src/tag-names-mpf-ifd.js +2 -2
- package/src/tag-names-utils.js +38 -3
- package/src/tags-helpers.js +20 -0
- package/src/utils.js +102 -16
- package/src/xmp-tag-names.js +1 -1
- package/src/xmp-tags.js +9 -6
package/README.md
CHANGED
|
@@ -23,21 +23,20 @@ You can try it out on the
|
|
|
23
23
|
|
|
24
24
|
**Support table**
|
|
25
25
|
|
|
26
|
-
| File type | Exif | IPTC
|
|
27
|
-
|
|
|
28
|
-
| JPEG | **yes** | **yes**
|
|
29
|
-
| JPEG XL*** | **yes** |
|
|
30
|
-
| TIFF | **yes** | **yes**
|
|
31
|
-
| PNG | **yes** | **yes**
|
|
32
|
-
| HEIC/HEIF | **yes** |
|
|
33
|
-
| AVIF | **yes** |
|
|
34
|
-
| WebP | **yes** |
|
|
35
|
-
| GIF | N/A | N/A
|
|
26
|
+
| File type | Exif | IPTC | XMP | ICC | MPF | Photoshop | MakerNote | Thumbnail | Image details |
|
|
27
|
+
| -----------------------|---------|------------------------------|---------|------------------------------|---------|---------------|--------------------|-----------|---------------|
|
|
28
|
+
| JPEG | **yes** | **yes** | **yes** | **yes** | **yes** | **some*** | **some**** | **yes** | **yes** |
|
|
29
|
+
| JPEG XL*** | **yes** | **yes****** | **yes** | **some****** | N/A | **some*** | **some**** | **yes** | **yes** |
|
|
30
|
+
| TIFF | **yes** | **yes** | **yes** | **yes** | N/A | **some*** | **some**** | **yes** | N/A |
|
|
31
|
+
| PNG | **yes** | **yes** | **yes** | **yes** | N/A | **some*** | **some**** | **yes** | **yes** |
|
|
32
|
+
| HEIC/HEIF | **yes** | **yes****** | **yes** | **yes** | N/A | **some*** | **some**** | **yes** | **yes** |
|
|
33
|
+
| AVIF | **yes** | **yes****** | **yes** | **yes** | N/A | **some*** | **some**** | **yes** | **yes** |
|
|
34
|
+
| WebP | **yes** | **yes****** | **yes** | **yes** | N/A | **some*** | **some**** | **yes** | **yes** |
|
|
35
|
+
| GIF | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A | **yes** |
|
|
36
36
|
|
|
37
37
|
- `MakerNote` = Manufacturers' proprietary MakerNote tags.
|
|
38
38
|
- `Image details` = image width, height, etc. read from image header.
|
|
39
39
|
- `N/A` = The feature is not applicable to this file type.
|
|
40
|
-
- `???` = may be supported but has not been tested.
|
|
41
40
|
- `*` = A draft implementation of Photoshop tags have been added with
|
|
42
41
|
`ClippingPathName` and `PathInformation` currently supported. Photoshop tags
|
|
43
42
|
are very different from other tags and need a lot of extra code so they have
|
|
@@ -49,6 +48,13 @@ You can try it out on the
|
|
|
49
48
|
compression. This is supported in some environments when using
|
|
50
49
|
`async: true`. See the [Asynchronous tags](#asynchronous-tags) and
|
|
51
50
|
[Custom decompression](#custom-decompression) sections for details.
|
|
51
|
+
JPEG XL defines no MPF block. A JPEG recompressed to JPEG XL keeps its MPF
|
|
52
|
+
segment only in its JPEG reconstruction data, which ExifReader does not
|
|
53
|
+
read.
|
|
54
|
+
- `****` = Read from the Exif data, where the `IPTC-NAA` and `ICC_Profile`
|
|
55
|
+
tags can carry them, in the same way as for TIFF files. The HEIC/HEIF,
|
|
56
|
+
AVIF and WebP formats define no IPTC block of their own. The ICC profile
|
|
57
|
+
inside a JPEG XL codestream is not read.
|
|
52
58
|
|
|
53
59
|
If you're missing something that you think should be supported, file an issue
|
|
54
60
|
with an attached example image and I'll see what I can do.
|
|
@@ -202,20 +208,25 @@ come straight from the image and can contain arbitrary text, including HTML-like
|
|
|
202
208
|
markup. Never insert them into a page as HTML (for example through `innerHTML`)
|
|
203
209
|
without escaping or sanitizing them first, otherwise a crafted image could lead
|
|
204
210
|
to cross-site scripting. Use `textContent`, your framework's escaping, or a
|
|
205
|
-
sanitizer such as DOMPurify when displaying metadata.
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
211
|
+
sanitizer such as DOMPurify when displaying metadata.
|
|
212
|
+
|
|
213
|
+
The property names inside a tag value come from the image too, and a tag whose
|
|
214
|
+
name is `__proto__` is kept under that name as a regular property, so it does
|
|
215
|
+
not replace the prototype of the object holding it. A tag whose name comes from
|
|
216
|
+
the image and is the name of an `Object.prototype` method, such as
|
|
217
|
+
`hasOwnProperty`, `toString` or `constructor`, is returned under that name with
|
|
218
|
+
`_` appended (`hasOwnProperty_`), so it does not hide the method on the result
|
|
219
|
+
object or on a group object, and `includeTags` and `excludeTags` match it by
|
|
220
|
+
that returned name. The same applies to the property names inside an XMP tag
|
|
221
|
+
value (structure members, members of list items and children of `rdf:value`)
|
|
222
|
+
and to the keys of an XMP tag's `attributes`. A value parsed from an XMP
|
|
223
|
+
`rdf:value` element that holds child elements other than a list is returned as
|
|
224
|
+
an object without a prototype. An XMP qualifier in `attributes` that holds
|
|
225
|
+
child elements is returned as its element tree, with the element and attribute
|
|
226
|
+
names unchanged and kept in objects without a prototype. Such an object has no
|
|
227
|
+
inherited methods, and copying it into an object of your own with
|
|
228
|
+
`Object.assign` or a deep merge helper without filtering the keys could let a
|
|
229
|
+
crafted image replace that object's prototype.
|
|
219
230
|
|
|
220
231
|
#### Grouping
|
|
221
232
|
|
|
@@ -274,23 +285,23 @@ For PNG, filtering is done with the `png` group only. (The `pngFile` and
|
|
|
274
285
|
`pngText` groups exist in `expanded` output today, but `png` is the filtering
|
|
275
286
|
key and those groups will be deprecated later.)
|
|
276
287
|
|
|
277
|
-
| Group key | Description
|
|
278
|
-
| ------------- |
|
|
279
|
-
| `exif` | Exif tags (including GPS IFD, interoperability).
|
|
280
|
-
| `iptc` | IPTC tags.
|
|
281
|
-
| `xmp` | XMP tags.
|
|
282
|
-
| `icc` | ICC profile tags.
|
|
283
|
-
| `photoshop` | Photoshop resource tags.
|
|
284
|
-
| `makerNotes` | MakerNote tags (e.g. Canon/Pentax).
|
|
285
|
-
| `mpf` | MPF tags.
|
|
286
|
-
| `file` | JPEG file details and `FileType`.
|
|
287
|
-
| `jfif` | JFIF tags.
|
|
288
|
-
| `png` | PNG header, chunk, and text tags.
|
|
289
|
-
| `riff` | WebP (RIFF) tags.
|
|
290
|
-
| `gif` | GIF tags.
|
|
291
|
-
| `gps` | Computed GPS group (only when `expanded: true`).
|
|
292
|
-
| `composite` | Composite tags (e.g. FieldOfView).
|
|
293
|
-
| `thumbnail` | Top-level `Thumbnail` output.
|
|
288
|
+
| Group key | Description | Supports IDs |
|
|
289
|
+
| ------------- | ----------------------------------------------------------------------------- | ------------ |
|
|
290
|
+
| `exif` | Exif tags (including GPS IFD, interoperability). | yes |
|
|
291
|
+
| `iptc` | IPTC tags. | yes |
|
|
292
|
+
| `xmp` | XMP tags. | no |
|
|
293
|
+
| `icc` | ICC profile tags. | no |
|
|
294
|
+
| `photoshop` | Photoshop resource tags. | yes |
|
|
295
|
+
| `makerNotes` | MakerNote tags (e.g. Canon/Pentax). | yes |
|
|
296
|
+
| `mpf` | MPF tags. | yes |
|
|
297
|
+
| `file` | JPEG file details, image details of JPEG XL, HEIC/HEIF and AVIF, and `FileType`. | no |
|
|
298
|
+
| `jfif` | JFIF tags. | no |
|
|
299
|
+
| `png` | PNG header, chunk, and text tags. | no |
|
|
300
|
+
| `riff` | WebP (RIFF) tags. | no |
|
|
301
|
+
| `gif` | GIF tags. | no |
|
|
302
|
+
| `gps` | Computed GPS group (only when `expanded: true`). | no |
|
|
303
|
+
| `composite` | Composite tags (e.g. FieldOfView). | no |
|
|
304
|
+
| `thumbnail` | Top-level `Thumbnail` output. | no |
|
|
294
305
|
|
|
295
306
|
**Important: dependency tags**
|
|
296
307
|
|
|
@@ -298,8 +309,8 @@ Some tags act as pointers or containers to other metadata. Excluding them can
|
|
|
298
309
|
cause other tags or entire groups to disappear. Some important examples:
|
|
299
310
|
|
|
300
311
|
- `Exif IFD Pointer`, `GPS Info IFD Pointer`, `Interoperability IFD Pointer`
|
|
301
|
-
- `IPTC-NAA` (
|
|
302
|
-
`ICC_Profile` (
|
|
312
|
+
- `IPTC-NAA` (Exif embedded IPTC), `ApplicationNotes` (Exif embedded XMP),
|
|
313
|
+
`ICC_Profile` (Exif embedded ICC)
|
|
303
314
|
- `MakerNote` and `Make` (maker note parsing)
|
|
304
315
|
- `ImageSourceData` and `PhotoshopSettings` (Photoshop parsing)
|
|
305
316
|
- `JPEGInterchangeFormat` and `JPEGInterchangeFormatLength` (thumbnails)
|
|
@@ -490,6 +501,10 @@ Block `type` reuses the filtering-group vocabulary (`exif`, `iptc`, `xmp`,
|
|
|
490
501
|
`icc`, `mpf`, `jfif`, `file`, `png`, `riff`, `gif`), plus `mpfImage` for the
|
|
491
502
|
sub-images of an MPF Multi-Picture JPEG. The same type may appear more than
|
|
492
503
|
once (multi-chunk ICC, extended XMP), one entry per physical container.
|
|
504
|
+
ExifReader records at most 4,096 of the containers it finds while scanning
|
|
505
|
+
the file; in a file with more, the last one recorded keeps its own type and is
|
|
506
|
+
widened to cover all the rest, so `start`, `end` and the `0..end` slice still
|
|
507
|
+
cover every metadata byte. `mpfImage` blocks come on top of these.
|
|
493
508
|
|
|
494
509
|
Typical workflow:
|
|
495
510
|
|
|
@@ -664,6 +679,11 @@ import {DOMParser, onErrorStopParsing} from '@xmldom/xmldom';
|
|
|
664
679
|
const tags = ExifReader.load(fileBuffer, {domParser: new DOMParser({onError: onErrorStopParsing})});
|
|
665
680
|
```
|
|
666
681
|
|
|
682
|
+
Use `xmldom` 0.9.12 or later. ExifReader limits how deeply XMP elements can
|
|
683
|
+
nest and how many markup nodes a packet can have, and it checks those limits
|
|
684
|
+
the way `xmldom` 0.9 reads the markup. With 0.8, a crafted file can get past
|
|
685
|
+
them and make parsing slow.
|
|
686
|
+
|
|
667
687
|
The `onError` option is needed to avoid a [seemingly infinite loop for some
|
|
668
688
|
XMLs](https://github.com/xmldom/xmldom/issues/501). Unfortunately `linkedom` has
|
|
669
689
|
the same problem but does not have this option and will therefore get stuck on
|
|
@@ -942,10 +962,10 @@ Possible modules to include or exclude:
|
|
|
942
962
|
| `webp` | WebP images. |
|
|
943
963
|
| `jxl` | JPEG XL images. |
|
|
944
964
|
| `gif` | GIF images. |
|
|
945
|
-
| `file` | JPEG file details: image width, height etc.
|
|
965
|
+
| `file` | JPEG file details: image width, height etc. The image details of JPEG XL, HEIC/HEIF and AVIF files come with their format module. |
|
|
946
966
|
| `jfif` | JFIF details in JPEG files: resolution, thumbnail etc. |
|
|
947
967
|
| `png_file` | PNG file details: image width, height etc. |
|
|
948
|
-
| `exif` | Regular Exif tags. If excluded, will also exclude `photoshop`, `maker_notes`, and `thumbnail`.
|
|
968
|
+
| `exif` | Regular Exif tags. If excluded, will also exclude `photoshop`, `maker_notes`, and `thumbnail`. Also excludes the IPTC, XMP and ICC tags that are read from the Exif data, which in TIFF files is all of them. |
|
|
949
969
|
| `iptc` | IPTC tags. |
|
|
950
970
|
| `xmp` | XMP tags. |
|
|
951
971
|
| `icc` | ICC color profile tags. |
|