exifreader 4.32.0 → 4.34.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
@@ -3,8 +3,8 @@ ExifReader
3
3
 
4
4
  ExifReader is a JavaScript library that parses image files and extracts the
5
5
  metadata. It can also extract an embedded thumbnail. It can be used either in a
6
- browser or from Node. Supports JPEG, TIFF, PNG, HEIC, WebP, and GIF files with
7
- Exif, IPTC, XMP, ICC, and MPF metadata (depending on file type).
6
+ browser or from Node. Supports JPEG, TIFF, PNG, HEIC, AVIF, WebP, and GIF files
7
+ with Exif, IPTC, XMP, ICC, MPF, and more metadata (depending on file type).
8
8
 
9
9
  ExifReader is highly and easily configurable and the resulting bundle can be as
10
10
  small as **~4 KiB** (gzipped) if you're only interested in a few tags (e.g. date
@@ -175,6 +175,9 @@ Where `file` is one of
175
175
  * URL (browser or Node.js; remember that in a browser context the remote server
176
176
  has to set CORS headers that allow for remote loading of the file)
177
177
 
178
+ **Tip:** To read metadata from an `HTMLImageElement`, wait for its `load` event
179
+ and call `ExifReader.load(image.src)`. The browser should reuse the cached file.
180
+
178
181
  #### Load the file yourself (synchronous API)
179
182
 
180
183
  ```javascript
@@ -290,13 +293,14 @@ it's common for the metadata to be spread out over a larger area so please try
290
293
  it out on your set of files to know if it's suitable for your situation.
291
294
 
292
295
  Note that this option only works when ExifReader handles the loading of the
293
- file. If e.g. a JavaScript File object from a form file field is passed into
294
- ExifReader the whole file will already have been loaded into memory and it's too
295
- late. More specifically the length option will work for 1. local files when
296
- running through Node.js, and 2. remote files when passing a URL. For the latter,
297
- if doing this through a web browser, make sure the remote server is either on
298
- the same origin (domain) as your script or that the server is passing correct
299
- CORS headers, specifically allowing the `Range` header.
296
+ file. If e.g. an already loaded ArrayBuffer or Buffer is passed into ExifReader,
297
+ the whole file will already have been loaded into memory and it's too late.
298
+ More specifically the length option will work for 1. local files when running
299
+ through Node.js, 2. remote files when passing a URL, and 3. browser File objects
300
+ (e.g., from form file fields). For remote files accessed through a web browser,
301
+ make sure the remote server is either on the same origin (domain) as your script
302
+ or that the server is passing correct CORS headers, specifically allowing the
303
+ `Range` header.
300
304
 
301
305
  #### Unknown tags
302
306
 
@@ -311,6 +315,40 @@ const tags = ExifReader.load(fileBuffer, {includeUnknown: true});
311
315
  If you discover an unknown tag that should be handled by ExifReader, please
312
316
  reach out by filing an issue.
313
317
 
318
+ #### Computed tag values (opt-in)
319
+
320
+ ExifReader exposes three different values per Exif tag:
321
+
322
+ - **`value`**: A stable, raw-ish value that mirrors how the tag is stored in the
323
+ file.
324
+ - **`description`**: A human-friendly value meant for display.
325
+ - **`computed`**: An opt-in, type-aware value. This will often be the same as
326
+ `value` except for RATIONAL/SRATIONAL and ASCII tags.
327
+
328
+ Enable the `computed` value by passing `computed: true` in the options:
329
+
330
+ ```javascript
331
+ const tags = ExifReader.load(fileBuffer, {computed: true});
332
+
333
+ const make = tags['Make'].computed; // e.g. "Apple"
334
+ const xResolution = tags['XResolution'].computed; // e.g. 72
335
+ ```
336
+
337
+ `computed` is only added for tags parsed from TIFF IFD structures (Exif/GPS/etc,
338
+ including maker notes, MPF, and the Thumbnail IFD). It is not currently added to
339
+ XMP/IPTC/ICC tags or PNG text tags.
340
+
341
+ The `computed` conversion rules are based on the TIFF tag type:
342
+
343
+ - **ASCII**: If `value` contains a single string, `computed` is that string.
344
+ Otherwise `computed` is a string array.
345
+ - **RATIONAL / SRATIONAL**: `computed` is a number (or an array of numbers).
346
+ Division by zero yields `null`.
347
+ - **All other types**: `computed` equals `value`.
348
+
349
+ Note that `computed` may evolve in minor versions as the feature matures. If you
350
+ need a value with the strongest stability guarantees, prefer `value`.
351
+
314
352
  ### GPS
315
353
 
316
354
  If `expanded: true` is specified in the options, there will be a `gps` group.
@@ -585,6 +623,9 @@ Changelog
585
623
 
586
624
  A selection of notable changes.
587
625
 
626
+ - **December 2025**:
627
+ - Add the `computed` tag property that are a middle way between the raw
628
+ `value` and the human-friendly `description`.
588
629
  - **October 2024**:
589
630
  - Add support for some proprietary tags from Canon cameras.
590
631
  - **December 2023**: