exifreader 4.27.0 → 4.28.1
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/dist/exif-reader.js +1 -1
- package/dist/exif-reader.js.map +1 -1
- package/exif-reader.d.ts +13 -1
- package/package.json +1 -1
- package/src/composite.js +75 -0
- package/src/exif-reader.js +10 -0
- package/src/tag-names-exif-ifd.js +2 -2
package/exif-reader.d.ts
CHANGED
|
@@ -208,6 +208,7 @@ export interface ExpandedTags {
|
|
|
208
208
|
gps?: GpsTags
|
|
209
209
|
photoshop?: PhotoshopTags;
|
|
210
210
|
makerNotes?: CanonTags;
|
|
211
|
+
composite?: CompositeTags;
|
|
211
212
|
}
|
|
212
213
|
|
|
213
214
|
interface GpsTags {
|
|
@@ -264,6 +265,17 @@ interface CanonTags {
|
|
|
264
265
|
};
|
|
265
266
|
}
|
|
266
267
|
|
|
268
|
+
interface CompositeTags {
|
|
269
|
+
ScaleFactorTo35mmEquivalent?: {
|
|
270
|
+
value: number,
|
|
271
|
+
description: string,
|
|
272
|
+
},
|
|
273
|
+
FieldOfView?: {
|
|
274
|
+
value: number,
|
|
275
|
+
description: string,
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
267
279
|
export function load(data: ArrayBuffer | SharedArrayBuffer | Buffer): Tags;
|
|
268
280
|
export function load(data: ArrayBuffer | SharedArrayBuffer | Buffer, options: {expanded: true, includeUnknown?: boolean, length?: number, async?: false}): ExpandedTags;
|
|
269
281
|
export function load(data: ArrayBuffer | SharedArrayBuffer | Buffer, options: {expanded?: false, includeUnknown?: boolean, length?: number, async?: false}): Tags;
|
|
@@ -525,7 +537,7 @@ interface IccTags {
|
|
|
525
537
|
[name: string]: ValueTag;
|
|
526
538
|
}
|
|
527
539
|
|
|
528
|
-
export type Tags = XmpTags & IccTags & PngTags & RiffTags & GifTags & PhotoshopTags & CanonTags & {
|
|
540
|
+
export type Tags = XmpTags & IccTags & PngTags & RiffTags & GifTags & PhotoshopTags & CanonTags & CompositeTags & {
|
|
529
541
|
'Thumbnail'?: ThumbnailTags;
|
|
530
542
|
'Images'?: MPFImageTags[],
|
|
531
543
|
} & {
|
package/package.json
CHANGED
package/src/composite.js
ADDED
|
@@ -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
|
+
}
|
package/src/exif-reader.js
CHANGED
|
@@ -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: {
|