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 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 | XMP | ICC | MPF | Photoshop | MakerNote | Thumbnail | Image details |
27
- | -----------------------|---------|---------|---------|---------|---------|---------------|--------------------|-----------|---------------|
28
- | JPEG | **yes** | **yes** | **yes** | **yes** | **yes** | **some*** | **some**** | **yes** | **yes** |
29
- | JPEG XL*** | **yes** | no | **yes** | no | no | no | **some**** | ??? | **yes** |
30
- | TIFF | **yes** | **yes** | **yes** | **yes** | ??? | **some*** | **some**** | **yes** | N/A |
31
- | PNG | **yes** | **yes** | **yes** | **yes** | ??? | ??? | **some**** | **yes** | **yes** |
32
- | HEIC/HEIF | **yes** | no | **yes** | **yes** | ??? | ??? | **some**** | **yes** | no |
33
- | AVIF | **yes** | no | **yes** | **yes** | ??? | ??? | **some**** | **yes** | no |
34
- | WebP | **yes** | no | **yes** | **yes** | ??? | ??? | **some**** | **yes** | **yes** |
35
- | GIF | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A | **yes** |
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. The property names inside
206
- a tag value come from the image too, and a tag whose name is `__proto__` is kept
207
- under that name as a regular property, so it does not replace the prototype of
208
- the object holding it. A tag whose name comes from the image and is the name of
209
- an `Object.prototype` method, such as `hasOwnProperty`, `toString` or
210
- `constructor`, is returned under that name with `_` appended
211
- (`hasOwnProperty_`), so it does not hide the method on the result object or on
212
- a group object, and `includeTags` and `excludeTags` match it by that returned
213
- name. Property names inside a tag value are not changed in this way. A value
214
- parsed from an XMP `rdf:value` element that holds child elements other than a
215
- list is returned as an object without a prototype.
216
- Such an object has no inherited methods, and copying it into an object of your
217
- own with `Object.assign` or a deep merge helper without filtering the keys could
218
- let a crafted image replace that object's prototype.
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 | Supports IDs |
278
- | ------------- | ------------------------------------------------ | ------------ |
279
- | `exif` | Exif tags (including GPS IFD, interoperability). | yes |
280
- | `iptc` | IPTC tags. | yes |
281
- | `xmp` | XMP tags. | no |
282
- | `icc` | ICC profile tags. | no |
283
- | `photoshop` | Photoshop resource tags. | yes |
284
- | `makerNotes` | MakerNote tags (e.g. Canon/Pentax). | yes |
285
- | `mpf` | MPF tags. | yes |
286
- | `file` | JPEG file details and `FileType`. | no |
287
- | `jfif` | JFIF tags. | no |
288
- | `png` | PNG header, chunk, and text tags. | no |
289
- | `riff` | WebP (RIFF) tags. | no |
290
- | `gif` | GIF tags. | no |
291
- | `gps` | Computed GPS group (only when `expanded: true`). | no |
292
- | `composite` | Composite tags (e.g. FieldOfView). | no |
293
- | `thumbnail` | Top-level `Thumbnail` output. | no |
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` (TIFF embedded IPTC), `ApplicationNotes` (TIFF embedded XMP),
302
- `ICC_Profile` (TIFF embedded ICC)
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`. For TIFF files, excluding this will also exclude IPTC, XMP, and ICC. |
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. |