exifreader 4.27.0 → 4.28.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exifreader",
3
- "version": "4.27.0",
3
+ "version": "4.28.0",
4
4
  "description": "Library that parses Exif metadata in images.",
5
5
  "author": "Mattias Wallander <mattias@wallander.eu>",
6
6
  "repository": {
@@ -0,0 +1,75 @@
1
+ /* This Source Code Form is subject to the terms of the Mozilla Public
2
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
+
5
+ export default {
6
+ get,
7
+ };
8
+
9
+ function get(tags, expanded) {
10
+ const compositeTags = {};
11
+ let hasCompositeTags = false;
12
+
13
+ const focalLength = getTagValue(tags, 'FocalLength', expanded);
14
+ const focalLengthIn35mmFilm = getTagValue(tags, 'FocalLengthIn35mmFilm', expanded);
15
+
16
+ const scaleFactorTo35mmEquivalent = getScaleFactorTo35mmEquivalent(focalLength, focalLengthIn35mmFilm);
17
+ if (scaleFactorTo35mmEquivalent) {
18
+ compositeTags.ScaleFactorTo35mmEquivalent = scaleFactorTo35mmEquivalent;
19
+ hasCompositeTags = true;
20
+ }
21
+
22
+ const fieldOfView = getFieldOfView(focalLengthIn35mmFilm);
23
+ if (fieldOfView) {
24
+ compositeTags.FieldOfView = fieldOfView;
25
+ hasCompositeTags = true;
26
+ }
27
+
28
+ if (hasCompositeTags) {
29
+ return compositeTags;
30
+ }
31
+
32
+ return undefined;
33
+ }
34
+
35
+ function getTagValue(tags, tagName, expanded) {
36
+ if (expanded && tags.exif && tags.exif[tagName]) {
37
+ return tags.exif[tagName].value;
38
+ }
39
+ if (!expanded && tags[tagName]) {
40
+ return tags[tagName].value;
41
+ }
42
+ return undefined;
43
+ }
44
+
45
+ function getScaleFactorTo35mmEquivalent(focalLength, focalLengthIn35mmFilm) {
46
+ if (focalLength && focalLengthIn35mmFilm) {
47
+ try {
48
+ const value = focalLengthIn35mmFilm / (focalLength[0] / focalLength[1]);
49
+ return {
50
+ value,
51
+ description: value.toFixed(1),
52
+ };
53
+ } catch (error) {
54
+ // Ignore.
55
+ }
56
+ }
57
+ return undefined;
58
+ }
59
+
60
+ function getFieldOfView(focalLengthIn35mmFilm) {
61
+ const FULL_FRAME_SENSOR_WIDTH_MM = 36;
62
+
63
+ if (focalLengthIn35mmFilm) {
64
+ try {
65
+ const value = 2 * Math.atan(FULL_FRAME_SENSOR_WIDTH_MM / (2 * focalLengthIn35mmFilm)) * (180 / Math.PI);
66
+ return {
67
+ value,
68
+ description: value.toFixed(1) + ' deg',
69
+ };
70
+ } catch (error) {
71
+ // Ignore.
72
+ }
73
+ }
74
+ return undefined;
75
+ }
@@ -29,6 +29,7 @@ import PngTags from './png-tags.js';
29
29
  import Vp8xTags from './vp8x-tags.js';
30
30
  import GifFileTags from './gif-file-tags.js';
31
31
  import Thumbnail from './thumbnail.js';
32
+ import Composite from './composite.js';
32
33
  import exifErrors from './errors.js';
33
34
 
34
35
  export default {
@@ -419,6 +420,15 @@ export function loadView(
419
420
  }
420
421
  }
421
422
 
423
+ const composite = Composite.get(tags, expanded);
424
+ if (composite) {
425
+ if (expanded) {
426
+ tags.composite = composite;
427
+ } else {
428
+ tags = objectAssign({}, tags, composite);
429
+ }
430
+ }
431
+
422
432
  const thumbnail = (Constants.USE_JPEG || Constants.USE_WEBP)
423
433
  && Constants.USE_EXIF
424
434
  && Constants.USE_THUMBNAIL
@@ -295,12 +295,12 @@ export default {
295
295
  }
296
296
  },
297
297
  0xa405: {
298
- 'name': 'FocalLengthIn35mmFilm',
298
+ 'name': 'FocalLengthIn35mmFilm', // Sometimes called FocalLengthIn35mmFormat.
299
299
  'description': (value) => {
300
300
  if (value === 0) {
301
301
  return 'Unknown';
302
302
  }
303
- return value;
303
+ return value + ' mm';
304
304
  }
305
305
  },
306
306
  0xa406: {