exifreader 4.53.0 → 4.55.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 +404 -33
- package/bin/analyze.js +139 -9
- package/bin/build-pages.js +21 -35
- package/bin/cli.js +81 -13
- package/bin/generate-tag-modules.js +287 -0
- package/dist/exif-reader.js +1 -1
- package/dist/exif-reader.js.map +1 -1
- package/exif-reader.d.ts +213 -38
- package/package.json +71 -11
- package/src/base64-image.js +27 -0
- package/src/composable/brand.js +10 -0
- package/src/composable/composition-tag-filter.js +97 -0
- package/src/composable/composition.js +195 -0
- package/src/composable/core.d.ts +148 -0
- package/src/composable/core.js +526 -0
- package/src/composable/exif-block-reader.js +197 -0
- package/src/composable/formats/avif.js +19 -0
- package/src/composable/formats/gif.js +28 -0
- package/src/composable/formats/heic.js +19 -0
- package/src/composable/formats/iso-bmff-file-reader.js +14 -0
- package/src/composable/formats/jpeg.js +55 -0
- package/src/composable/formats/jxl.js +30 -0
- package/src/composable/formats/png.js +187 -0
- package/src/composable/formats/tiff.js +18 -0
- package/src/composable/formats/webp.js +28 -0
- package/src/composable/formats/xml.js +18 -0
- package/src/composable/formats.d.ts +17 -0
- package/src/composable/formats.js +17 -0
- package/src/composable/group-helpers.js +129 -0
- package/src/composable/groups/canon.js +26 -0
- package/src/composable/groups/composite.js +43 -0
- package/src/composable/groups/exif.js +48 -0
- package/src/composable/groups/gps.js +75 -0
- package/src/composable/groups/icc.js +52 -0
- package/src/composable/groups/iptc.js +86 -0
- package/src/composable/groups/maker-notes.js +21 -0
- package/src/composable/groups/mpf.js +25 -0
- package/src/composable/groups/pentax.js +34 -0
- package/src/composable/groups/photoshop.js +18 -0
- package/src/composable/groups/thumbnail.js +131 -0
- package/src/composable/groups/xmp.js +118 -0
- package/src/composable/groups.d.ts +20 -0
- package/src/composable/groups.js +105 -0
- package/src/composable/iptc-block-reader.js +44 -0
- package/src/composable/read-view.js +165 -0
- package/src/composable/tag-binding-name.js +17 -0
- package/src/composable/tags/exif.d.ts +295 -0
- package/src/composable/tags/exif.js +396 -0
- package/src/composable/tags/iptc.d.ts +84 -0
- package/src/composable/tags/iptc.js +109 -0
- package/src/composable/value-budget.js +24 -0
- package/src/composite.js +2 -2
- package/src/decompression.js +60 -0
- package/src/dom-parser.js +5 -6
- package/src/engine.js +332 -0
- package/src/errors.js +8 -2
- package/src/exif-reader.d.ts +8 -0
- package/src/exif-reader.js +118 -1121
- package/src/file-loaders.js +74 -1
- package/src/file-tags.js +9 -9
- package/src/image-header-avif.js +7 -8
- package/src/image-header-gif.js +9 -10
- package/src/image-header-heic.js +7 -8
- package/src/image-header-iso-bmff.js +71 -92
- package/src/image-header-jpeg.js +60 -59
- package/src/image-header-jxl.js +59 -65
- package/src/image-header-png.js +199 -76
- package/src/image-header-tiff.js +7 -4
- package/src/image-header-webp.js +29 -35
- package/src/image-header.js +25 -59
- package/src/iptc-tag-names-descriptions.js +334 -0
- package/src/iptc-tag-names.js +50 -306
- package/src/iptc-tags.js +41 -27
- package/src/jfif-tags.js +9 -9
- package/src/load-auto.js +2 -2
- package/src/loadview-pipeline.js +197 -498
- package/src/mpf-tags.js +10 -7
- package/src/node-require.js +15 -2
- package/src/png-text-tags.js +90 -327
- package/src/tag-filter-config.js +24 -15
- package/src/tag-filter.js +67 -3
- package/src/tag-names-0th-ifd-descriptions.js +232 -0
- package/src/tag-names-0th-ifd.js +49 -173
- package/src/tag-names-common.js +263 -211
- package/src/tag-names-exif-ifd-descriptions.js +249 -0
- package/src/tag-names-exif-ifd.js +55 -187
- package/src/tag-names-gps-ifd-descriptions.js +156 -0
- package/src/tag-names-gps-ifd.js +39 -146
- package/src/tag-names-utils.js +33 -10
- package/src/tags-helpers.js +14 -24
- package/src/tags.js +23 -11
- package/src/thumbnail.js +7 -5
- package/src/types.js +2 -0
- package/src/unsupported-format-error.js +21 -0
- package/src/utils.js +64 -119
- package/src/writer/exif-tag-table.js +321 -0
- package/src/xml.js +12 -15
- package/src/xmp-tag-names.js +42 -21
- package/src/xmp-tags.js +9 -10
- package/webpack.config.js +1 -1
|
@@ -0,0 +1,156 @@
|
|
|
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 function getGPSVersionIDDescription(value) {
|
|
6
|
+
if (value[0] === 2 && value[1] === 2 && value[2] === 0 && value[3] === 0) {
|
|
7
|
+
return 'Version 2.2';
|
|
8
|
+
}
|
|
9
|
+
return 'Unknown';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function getGPSLatitudeRefDescription(value) {
|
|
13
|
+
const ref = value.join('');
|
|
14
|
+
if (ref === 'N') {
|
|
15
|
+
return 'North latitude';
|
|
16
|
+
} else if (ref === 'S') {
|
|
17
|
+
return 'South latitude';
|
|
18
|
+
}
|
|
19
|
+
return 'Unknown';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function getGPSLongitudeRefDescription(value) {
|
|
23
|
+
const ref = value.join('');
|
|
24
|
+
if (ref === 'E') {
|
|
25
|
+
return 'East longitude';
|
|
26
|
+
} else if (ref === 'W') {
|
|
27
|
+
return 'West longitude';
|
|
28
|
+
}
|
|
29
|
+
return 'Unknown';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function getGPSAltitudeRefDescription(value) {
|
|
33
|
+
if (value === 0) {
|
|
34
|
+
return 'Sea level';
|
|
35
|
+
} else if (value === 1) {
|
|
36
|
+
return 'Sea level reference (negative value)';
|
|
37
|
+
}
|
|
38
|
+
return 'Unknown';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function getGPSAltitudeDescription(value) {
|
|
42
|
+
return (value[0] / value[1]) + ' m';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function getGPSTimeStampDescription(values) {
|
|
46
|
+
return values.map(([numerator, denominator]) => {
|
|
47
|
+
const num = numerator / denominator;
|
|
48
|
+
if (/^\d(\.|$)/.test(`${num}`)) {
|
|
49
|
+
return `0${num}`;
|
|
50
|
+
}
|
|
51
|
+
return num;
|
|
52
|
+
}).join(':');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function getGPSStatusDescription(value) {
|
|
56
|
+
const status = value.join('');
|
|
57
|
+
if (status === 'A') {
|
|
58
|
+
return 'Measurement in progress';
|
|
59
|
+
} else if (status === 'V') {
|
|
60
|
+
return 'Measurement Interoperability';
|
|
61
|
+
}
|
|
62
|
+
return 'Unknown';
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function getGPSMeasureModeDescription(value) {
|
|
66
|
+
const mode = value.join('');
|
|
67
|
+
if (mode === '2') {
|
|
68
|
+
return '2-dimensional measurement';
|
|
69
|
+
} else if (mode === '3') {
|
|
70
|
+
return '3-dimensional measurement';
|
|
71
|
+
}
|
|
72
|
+
return 'Unknown';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function getGPSSpeedRefDescription(value) {
|
|
76
|
+
const ref = value.join('');
|
|
77
|
+
if (ref === 'K') {
|
|
78
|
+
return 'Kilometers per hour';
|
|
79
|
+
} else if (ref === 'M') {
|
|
80
|
+
return 'Miles per hour';
|
|
81
|
+
} else if (ref === 'N') {
|
|
82
|
+
return 'Knots';
|
|
83
|
+
}
|
|
84
|
+
return 'Unknown';
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function getGPSTrackRefDescription(value) {
|
|
88
|
+
const ref = value.join('');
|
|
89
|
+
if (ref === 'T') {
|
|
90
|
+
return 'True direction';
|
|
91
|
+
} else if (ref === 'M') {
|
|
92
|
+
return 'Magnetic direction';
|
|
93
|
+
}
|
|
94
|
+
return 'Unknown';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function getGPSImgDirectionRefDescription(value) {
|
|
98
|
+
const ref = value.join('');
|
|
99
|
+
if (ref === 'T') {
|
|
100
|
+
return 'True direction';
|
|
101
|
+
} else if (ref === 'M') {
|
|
102
|
+
return 'Magnetic direction';
|
|
103
|
+
}
|
|
104
|
+
return 'Unknown';
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function getGPSDestLatitudeRefDescription(value) {
|
|
108
|
+
const ref = value.join('');
|
|
109
|
+
if (ref === 'N') {
|
|
110
|
+
return 'North latitude';
|
|
111
|
+
} else if (ref === 'S') {
|
|
112
|
+
return 'South latitude';
|
|
113
|
+
}
|
|
114
|
+
return 'Unknown';
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function getGPSDestLongitudeRefDescription(value) {
|
|
118
|
+
const ref = value.join('');
|
|
119
|
+
if (ref === 'E') {
|
|
120
|
+
return 'East longitude';
|
|
121
|
+
} else if (ref === 'W') {
|
|
122
|
+
return 'West longitude';
|
|
123
|
+
}
|
|
124
|
+
return 'Unknown';
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function getGPSDestBearingRefDescription(value) {
|
|
128
|
+
const ref = value.join('');
|
|
129
|
+
if (ref === 'T') {
|
|
130
|
+
return 'True direction';
|
|
131
|
+
} else if (ref === 'M') {
|
|
132
|
+
return 'Magnetic direction';
|
|
133
|
+
}
|
|
134
|
+
return 'Unknown';
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function getGPSDestDistanceRefDescription(value) {
|
|
138
|
+
const ref = value.join('');
|
|
139
|
+
if (ref === 'K') {
|
|
140
|
+
return 'Kilometers';
|
|
141
|
+
} else if (ref === 'M') {
|
|
142
|
+
return 'Miles';
|
|
143
|
+
} else if (ref === 'N') {
|
|
144
|
+
return 'Knots';
|
|
145
|
+
}
|
|
146
|
+
return 'Unknown';
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export function getGPSDifferentialDescription(value) {
|
|
150
|
+
if (value === 0) {
|
|
151
|
+
return 'Measurement without differential correction';
|
|
152
|
+
} else if (value === 1) {
|
|
153
|
+
return 'Differential correction applied';
|
|
154
|
+
}
|
|
155
|
+
return 'Unknown';
|
|
156
|
+
}
|
package/src/tag-names-gps-ifd.js
CHANGED
|
@@ -2,209 +2,109 @@
|
|
|
2
2
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
3
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
4
|
|
|
5
|
-
import {getEncodedString,
|
|
5
|
+
import {getEncodedString, getGpsCoordinateDescription} from './tag-names-utils.js';
|
|
6
|
+
import {
|
|
7
|
+
getGPSVersionIDDescription,
|
|
8
|
+
getGPSLatitudeRefDescription,
|
|
9
|
+
getGPSLongitudeRefDescription,
|
|
10
|
+
getGPSAltitudeRefDescription,
|
|
11
|
+
getGPSAltitudeDescription,
|
|
12
|
+
getGPSTimeStampDescription,
|
|
13
|
+
getGPSStatusDescription,
|
|
14
|
+
getGPSMeasureModeDescription,
|
|
15
|
+
getGPSSpeedRefDescription,
|
|
16
|
+
getGPSTrackRefDescription,
|
|
17
|
+
getGPSImgDirectionRefDescription,
|
|
18
|
+
getGPSDestLatitudeRefDescription,
|
|
19
|
+
getGPSDestLongitudeRefDescription,
|
|
20
|
+
getGPSDestBearingRefDescription,
|
|
21
|
+
getGPSDestDistanceRefDescription,
|
|
22
|
+
getGPSDifferentialDescription
|
|
23
|
+
} from './tag-names-gps-ifd-descriptions.js';
|
|
6
24
|
|
|
7
25
|
export default {
|
|
8
26
|
0x0000: {
|
|
9
27
|
'name': 'GPSVersionID',
|
|
10
|
-
'description':
|
|
11
|
-
if (value[0] === 2 && value[1] === 2 && value[2] === 0 && value[3] === 0) {
|
|
12
|
-
return 'Version 2.2';
|
|
13
|
-
}
|
|
14
|
-
return 'Unknown';
|
|
15
|
-
}
|
|
28
|
+
'description': getGPSVersionIDDescription
|
|
16
29
|
},
|
|
17
30
|
0x0001: {
|
|
18
31
|
'name': 'GPSLatitudeRef',
|
|
19
|
-
'description':
|
|
20
|
-
const ref = value.join('');
|
|
21
|
-
if (ref === 'N') {
|
|
22
|
-
return 'North latitude';
|
|
23
|
-
} else if (ref === 'S') {
|
|
24
|
-
return 'South latitude';
|
|
25
|
-
}
|
|
26
|
-
return 'Unknown';
|
|
27
|
-
}
|
|
32
|
+
'description': getGPSLatitudeRefDescription
|
|
28
33
|
},
|
|
29
34
|
0x0002: {
|
|
30
35
|
'name': 'GPSLatitude',
|
|
31
|
-
'description':
|
|
36
|
+
'description': getGpsCoordinateDescription
|
|
32
37
|
},
|
|
33
38
|
0x0003: {
|
|
34
39
|
'name': 'GPSLongitudeRef',
|
|
35
|
-
'description':
|
|
36
|
-
const ref = value.join('');
|
|
37
|
-
if (ref === 'E') {
|
|
38
|
-
return 'East longitude';
|
|
39
|
-
} else if (ref === 'W') {
|
|
40
|
-
return 'West longitude';
|
|
41
|
-
}
|
|
42
|
-
return 'Unknown';
|
|
43
|
-
}
|
|
40
|
+
'description': getGPSLongitudeRefDescription
|
|
44
41
|
},
|
|
45
42
|
0x0004: {
|
|
46
43
|
'name': 'GPSLongitude',
|
|
47
|
-
'description':
|
|
44
|
+
'description': getGpsCoordinateDescription
|
|
48
45
|
},
|
|
49
46
|
0x0005: {
|
|
50
47
|
'name': 'GPSAltitudeRef',
|
|
51
|
-
'description':
|
|
52
|
-
if (value === 0) {
|
|
53
|
-
return 'Sea level';
|
|
54
|
-
} else if (value === 1) {
|
|
55
|
-
return 'Sea level reference (negative value)';
|
|
56
|
-
}
|
|
57
|
-
return 'Unknown';
|
|
58
|
-
}
|
|
48
|
+
'description': getGPSAltitudeRefDescription
|
|
59
49
|
},
|
|
60
50
|
0x0006: {
|
|
61
51
|
'name': 'GPSAltitude',
|
|
62
|
-
'description':
|
|
63
|
-
return (value[0] / value[1]) + ' m';
|
|
64
|
-
}
|
|
52
|
+
'description': getGPSAltitudeDescription
|
|
65
53
|
},
|
|
66
54
|
0x0007: {
|
|
67
55
|
'name': 'GPSTimeStamp',
|
|
68
|
-
'description':
|
|
69
|
-
return values.map(([numerator, denominator]) => {
|
|
70
|
-
const num = numerator / denominator;
|
|
71
|
-
if (/^\d(\.|$)/.test(`${num}`)) {
|
|
72
|
-
return `0${num}`;
|
|
73
|
-
}
|
|
74
|
-
return num;
|
|
75
|
-
}).join(':');
|
|
76
|
-
}
|
|
56
|
+
'description': getGPSTimeStampDescription
|
|
77
57
|
},
|
|
78
58
|
0x0008: 'GPSSatellites',
|
|
79
59
|
0x0009: {
|
|
80
60
|
'name': 'GPSStatus',
|
|
81
|
-
'description':
|
|
82
|
-
const status = value.join('');
|
|
83
|
-
if (status === 'A') {
|
|
84
|
-
return 'Measurement in progress';
|
|
85
|
-
} else if (status === 'V') {
|
|
86
|
-
return 'Measurement Interoperability';
|
|
87
|
-
}
|
|
88
|
-
return 'Unknown';
|
|
89
|
-
}
|
|
61
|
+
'description': getGPSStatusDescription
|
|
90
62
|
},
|
|
91
63
|
0x000a: {
|
|
92
64
|
'name': 'GPSMeasureMode',
|
|
93
|
-
'description':
|
|
94
|
-
const mode = value.join('');
|
|
95
|
-
if (mode === '2') {
|
|
96
|
-
return '2-dimensional measurement';
|
|
97
|
-
} else if (mode === '3') {
|
|
98
|
-
return '3-dimensional measurement';
|
|
99
|
-
}
|
|
100
|
-
return 'Unknown';
|
|
101
|
-
}
|
|
65
|
+
'description': getGPSMeasureModeDescription
|
|
102
66
|
},
|
|
103
67
|
0x000b: 'GPSDOP',
|
|
104
68
|
0x000c: {
|
|
105
69
|
'name': 'GPSSpeedRef',
|
|
106
|
-
'description':
|
|
107
|
-
const ref = value.join('');
|
|
108
|
-
if (ref === 'K') {
|
|
109
|
-
return 'Kilometers per hour';
|
|
110
|
-
} else if (ref === 'M') {
|
|
111
|
-
return 'Miles per hour';
|
|
112
|
-
} else if (ref === 'N') {
|
|
113
|
-
return 'Knots';
|
|
114
|
-
}
|
|
115
|
-
return 'Unknown';
|
|
116
|
-
}
|
|
70
|
+
'description': getGPSSpeedRefDescription
|
|
117
71
|
},
|
|
118
72
|
0x000d: 'GPSSpeed',
|
|
119
73
|
0x000e: {
|
|
120
74
|
'name': 'GPSTrackRef',
|
|
121
|
-
'description':
|
|
122
|
-
const ref = value.join('');
|
|
123
|
-
if (ref === 'T') {
|
|
124
|
-
return 'True direction';
|
|
125
|
-
} else if (ref === 'M') {
|
|
126
|
-
return 'Magnetic direction';
|
|
127
|
-
}
|
|
128
|
-
return 'Unknown';
|
|
129
|
-
}
|
|
75
|
+
'description': getGPSTrackRefDescription
|
|
130
76
|
},
|
|
131
77
|
0x000f: 'GPSTrack',
|
|
132
78
|
0x0010: {
|
|
133
79
|
'name': 'GPSImgDirectionRef',
|
|
134
|
-
'description':
|
|
135
|
-
const ref = value.join('');
|
|
136
|
-
if (ref === 'T') {
|
|
137
|
-
return 'True direction';
|
|
138
|
-
} else if (ref === 'M') {
|
|
139
|
-
return 'Magnetic direction';
|
|
140
|
-
}
|
|
141
|
-
return 'Unknown';
|
|
142
|
-
}
|
|
80
|
+
'description': getGPSImgDirectionRefDescription
|
|
143
81
|
},
|
|
144
82
|
0x0011: 'GPSImgDirection',
|
|
145
83
|
0x0012: 'GPSMapDatum',
|
|
146
84
|
0x0013: {
|
|
147
85
|
'name': 'GPSDestLatitudeRef',
|
|
148
|
-
'description':
|
|
149
|
-
const ref = value.join('');
|
|
150
|
-
if (ref === 'N') {
|
|
151
|
-
return 'North latitude';
|
|
152
|
-
} else if (ref === 'S') {
|
|
153
|
-
return 'South latitude';
|
|
154
|
-
}
|
|
155
|
-
return 'Unknown';
|
|
156
|
-
}
|
|
86
|
+
'description': getGPSDestLatitudeRefDescription
|
|
157
87
|
},
|
|
158
88
|
0x0014: {
|
|
159
89
|
'name': 'GPSDestLatitude',
|
|
160
|
-
'description':
|
|
161
|
-
return (value[0][0] / value[0][1]) + (value[1][0] / value[1][1]) / 60 + (value[2][0] / value[2][1]) / 3600;
|
|
162
|
-
}
|
|
90
|
+
'description': getGpsCoordinateDescription
|
|
163
91
|
},
|
|
164
92
|
0x0015: {
|
|
165
93
|
'name': 'GPSDestLongitudeRef',
|
|
166
|
-
'description':
|
|
167
|
-
const ref = value.join('');
|
|
168
|
-
if (ref === 'E') {
|
|
169
|
-
return 'East longitude';
|
|
170
|
-
} else if (ref === 'W') {
|
|
171
|
-
return 'West longitude';
|
|
172
|
-
}
|
|
173
|
-
return 'Unknown';
|
|
174
|
-
}
|
|
94
|
+
'description': getGPSDestLongitudeRefDescription
|
|
175
95
|
},
|
|
176
96
|
0x0016: {
|
|
177
97
|
'name': 'GPSDestLongitude',
|
|
178
|
-
'description':
|
|
179
|
-
return (value[0][0] / value[0][1]) + (value[1][0] / value[1][1]) / 60 + (value[2][0] / value[2][1]) / 3600;
|
|
180
|
-
}
|
|
98
|
+
'description': getGpsCoordinateDescription
|
|
181
99
|
},
|
|
182
100
|
0x0017: {
|
|
183
101
|
'name': 'GPSDestBearingRef',
|
|
184
|
-
'description':
|
|
185
|
-
const ref = value.join('');
|
|
186
|
-
if (ref === 'T') {
|
|
187
|
-
return 'True direction';
|
|
188
|
-
} else if (ref === 'M') {
|
|
189
|
-
return 'Magnetic direction';
|
|
190
|
-
}
|
|
191
|
-
return 'Unknown';
|
|
192
|
-
}
|
|
102
|
+
'description': getGPSDestBearingRefDescription
|
|
193
103
|
},
|
|
194
104
|
0x0018: 'GPSDestBearing',
|
|
195
105
|
0x0019: {
|
|
196
106
|
'name': 'GPSDestDistanceRef',
|
|
197
|
-
'description':
|
|
198
|
-
const ref = value.join('');
|
|
199
|
-
if (ref === 'K') {
|
|
200
|
-
return 'Kilometers';
|
|
201
|
-
} else if (ref === 'M') {
|
|
202
|
-
return 'Miles';
|
|
203
|
-
} else if (ref === 'N') {
|
|
204
|
-
return 'Knots';
|
|
205
|
-
}
|
|
206
|
-
return 'Unknown';
|
|
207
|
-
}
|
|
107
|
+
'description': getGPSDestDistanceRefDescription
|
|
208
108
|
},
|
|
209
109
|
0x001a: 'GPSDestDistance',
|
|
210
110
|
0x001b: {
|
|
@@ -218,14 +118,7 @@ export default {
|
|
|
218
118
|
0x001d: 'GPSDateStamp',
|
|
219
119
|
0x001e: {
|
|
220
120
|
'name': 'GPSDifferential',
|
|
221
|
-
'description':
|
|
222
|
-
if (value === 0) {
|
|
223
|
-
return 'Measurement without differential correction';
|
|
224
|
-
} else if (value === 1) {
|
|
225
|
-
return 'Differential correction applied';
|
|
226
|
-
}
|
|
227
|
-
return 'Unknown';
|
|
228
|
-
}
|
|
121
|
+
'description': getGPSDifferentialDescription
|
|
229
122
|
},
|
|
230
123
|
0x001f: 'GPSHPositioningError'
|
|
231
124
|
};
|
package/src/tag-names-utils.js
CHANGED
|
@@ -7,7 +7,7 @@ import {getStringValueFromArray as getStringValue, getByteString} from './utils.
|
|
|
7
7
|
export {getStringValue};
|
|
8
8
|
|
|
9
9
|
export function getEncodedString(value) {
|
|
10
|
-
if (
|
|
10
|
+
if (isArrayWithoutCharacterCodes(value)) {
|
|
11
11
|
return getStringsText(value) || 'Undefined';
|
|
12
12
|
}
|
|
13
13
|
if (value.length >= 8) {
|
|
@@ -35,29 +35,27 @@ export function getEncodedString(value) {
|
|
|
35
35
|
* Converts the bytes of a version tag, such as ExifVersion, to a string. A
|
|
36
36
|
* value of strings (an ASCII-typed tag) is returned as its strings joined
|
|
37
37
|
* with ', ', as for other ASCII tags. A value that is not an array (a single
|
|
38
|
-
* byte, or '<faulty value>') is returned as
|
|
38
|
+
* byte, or '<faulty value>') is returned as its string.
|
|
39
39
|
* @param {number[]|string[]|number|string} value
|
|
40
|
-
* @returns {string
|
|
40
|
+
* @returns {string}
|
|
41
41
|
*/
|
|
42
42
|
export function getVersionString(value) {
|
|
43
43
|
if (Array.isArray(value)) {
|
|
44
|
-
if (
|
|
44
|
+
if (isArrayWithoutCharacterCodes(value)) {
|
|
45
45
|
return getStringsText(value);
|
|
46
46
|
}
|
|
47
47
|
return getByteString(value);
|
|
48
48
|
}
|
|
49
|
-
return value;
|
|
49
|
+
return String(value);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* piece was, index 0 included; a rational value holds number pairs. Neither
|
|
56
|
-
* has character codes to convert, and an empty array has none either.
|
|
53
|
+
* An ASCII-typed value holds strings, with a hole where an empty piece was,
|
|
54
|
+
* index 0 included, and a rational value holds number pairs.
|
|
57
55
|
* @param {*} value
|
|
58
56
|
* @returns {boolean} True for an array whose element 0 is not a number.
|
|
59
57
|
*/
|
|
60
|
-
export function
|
|
58
|
+
export function isArrayWithoutCharacterCodes(value) {
|
|
61
59
|
return Array.isArray(value) && typeof value[0] !== 'number';
|
|
62
60
|
}
|
|
63
61
|
|
|
@@ -88,6 +86,31 @@ export function getTableDescription(table, value) {
|
|
|
88
86
|
return Object.prototype.hasOwnProperty.call(table, key) ? table[key] : 'Unknown';
|
|
89
87
|
}
|
|
90
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Describes a GPS coordinate as its unsigned decimal value.
|
|
91
|
+
*
|
|
92
|
+
* @param {*} value The tag value, [numerator, denominator] pairs for the
|
|
93
|
+
* degrees, minutes and seconds. Pairs after the third are ignored.
|
|
94
|
+
* @returns {number} The decimal coordinate, or NaN when the value does not
|
|
95
|
+
* start with three pairs.
|
|
96
|
+
*/
|
|
97
|
+
export function getGpsCoordinateDescription(value) {
|
|
98
|
+
if (!startsWithThreeRationalPairs(value)) {
|
|
99
|
+
return NaN;
|
|
100
|
+
}
|
|
101
|
+
return getCalculatedGpsValue(value);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function startsWithThreeRationalPairs(value) {
|
|
105
|
+
return Array.isArray(value)
|
|
106
|
+
&& isRationalPair(value[0]) && isRationalPair(value[1]) && isRationalPair(value[2]);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function isRationalPair(value) {
|
|
110
|
+
return Array.isArray(value) && value.length === 2
|
|
111
|
+
&& typeof value[0] === 'number' && typeof value[1] === 'number';
|
|
112
|
+
}
|
|
113
|
+
|
|
91
114
|
export function getCalculatedGpsValue(value) {
|
|
92
115
|
return (value[0][0] / value[0][1]) + (value[1][0] / value[1][1]) / 60 + (value[2][0] / value[2][1]) / 3600;
|
|
93
116
|
}
|
package/src/tags-helpers.js
CHANGED
|
@@ -105,6 +105,8 @@ export function get0thIfdOffset(dataView, tiffHeaderOffset, byteOrder) {
|
|
|
105
105
|
* offset into the thumbnail IFD, whose entries are otherwise not charged to the
|
|
106
106
|
* value budget. Defaults to whether tagNames has an IFD_TYPE_1ST dictionary and
|
|
107
107
|
* tagFilter parses the thumbnail group.
|
|
108
|
+
* @param {Object} [valueOffsets] - Given, receives the offset of the MakerNote
|
|
109
|
+
* value as `MakerNote`, relative to the offset origin.
|
|
108
110
|
* @returns {Object} The read tags, keyed by tag name.
|
|
109
111
|
*/
|
|
110
112
|
export function readIfd(
|
|
@@ -119,7 +121,8 @@ export function readIfd(
|
|
|
119
121
|
groupKey = 'exif',
|
|
120
122
|
valueBudget = getValueBudget(dataView),
|
|
121
123
|
tagNames,
|
|
122
|
-
readThumbnailIfd = tagNames[IFD_TYPE_1ST] !== undefined && tagFilter.shouldParseGroup('thumbnail')
|
|
124
|
+
readThumbnailIfd = tagNames[IFD_TYPE_1ST] !== undefined && tagFilter.shouldParseGroup('thumbnail'),
|
|
125
|
+
valueOffsets = undefined
|
|
123
126
|
) {
|
|
124
127
|
const FIELD_COUNT_SIZE = Types.getTypeSize('SHORT');
|
|
125
128
|
const FIELD_SIZE = IFD_ENTRY_LENGTH;
|
|
@@ -160,9 +163,12 @@ export function readIfd(
|
|
|
160
163
|
if (computed) {
|
|
161
164
|
tags[tag.name].computed = getComputedTagValue(tag.tagType, tag.value);
|
|
162
165
|
}
|
|
163
|
-
if (
|
|
166
|
+
if (ifdType === IFD_TYPE_PENTAX && tag.name === 'LevelInfo') {
|
|
164
167
|
tags[tag.name].__offset = tag.__offset;
|
|
165
168
|
}
|
|
169
|
+
if (valueOffsets !== undefined && tag.name === 'MakerNote') {
|
|
170
|
+
valueOffsets.MakerNote = tag.__offset;
|
|
171
|
+
}
|
|
166
172
|
}
|
|
167
173
|
|
|
168
174
|
offset += FIELD_SIZE;
|
|
@@ -349,7 +355,7 @@ function readTag(
|
|
|
349
355
|
tagValue = getAsciiTagValue(tagValue, stringBudget);
|
|
350
356
|
}
|
|
351
357
|
|
|
352
|
-
let tagDescription = tagValue;
|
|
358
|
+
let tagDescription = getNumberAsString(tagValue);
|
|
353
359
|
|
|
354
360
|
if (tagNames[ifdType][tagCode] !== undefined) {
|
|
355
361
|
if ((tagNames[ifdType][tagCode]['name'] !== undefined) && (tagNames[ifdType][tagCode]['description'] !== undefined)) {
|
|
@@ -498,7 +504,11 @@ function getDescriptionFromTagValue(tagValue) {
|
|
|
498
504
|
if (tagValue instanceof Array) {
|
|
499
505
|
return tagValue.join(', ');
|
|
500
506
|
}
|
|
501
|
-
return tagValue;
|
|
507
|
+
return getNumberAsString(tagValue);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
function getNumberAsString(value) {
|
|
511
|
+
return typeof value === 'number' ? String(value) : value;
|
|
502
512
|
}
|
|
503
513
|
|
|
504
514
|
function getComputedTagValue(tagType, value) {
|
|
@@ -550,23 +560,3 @@ function getComputedRationalValue(rational) {
|
|
|
550
560
|
|
|
551
561
|
return numerator / denominator;
|
|
552
562
|
}
|
|
553
|
-
|
|
554
|
-
/**
|
|
555
|
-
* Removes the thumbnail IFD from the tags of an embedded Exif block and reads
|
|
556
|
-
* its image with `readThumbnail`, when given.
|
|
557
|
-
*
|
|
558
|
-
* @returns {object|undefined} The thumbnail tags when an image was read.
|
|
559
|
-
*/
|
|
560
|
-
export function takeEmbeddedExifThumbnail(readTags, dataView, tiffHeaderOffset, readThumbnail) {
|
|
561
|
-
const thumbnailIfdTags = readTags.Thumbnail;
|
|
562
|
-
if (!thumbnailIfdTags) {
|
|
563
|
-
return undefined;
|
|
564
|
-
}
|
|
565
|
-
delete readTags.Thumbnail;
|
|
566
|
-
|
|
567
|
-
if (!readThumbnail) {
|
|
568
|
-
return undefined;
|
|
569
|
-
}
|
|
570
|
-
const thumbnail = readThumbnail(dataView, thumbnailIfdTags, tiffHeaderOffset);
|
|
571
|
-
return thumbnail.image ? thumbnail : undefined;
|
|
572
|
-
}
|
package/src/tags.js
CHANGED
|
@@ -18,10 +18,18 @@ export default {
|
|
|
18
18
|
read,
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Reads the 0th, Exif, GPS and Interoperability IFDs, and the thumbnail IFD
|
|
23
|
+
* when asked to.
|
|
24
|
+
*
|
|
25
|
+
* One decoded-value budget is shared by the IFD reads so their combined
|
|
26
|
+
* decoded values stay proportional to the input. A caller passes its own to
|
|
27
|
+
* share it with later reads (the maker note, MPF and decompressed Exif).
|
|
28
|
+
*
|
|
29
|
+
* @returns {{tags: Object, byteOrder: number, makerNoteOffset: (number|undefined)}}
|
|
30
|
+
* `makerNoteOffset` is the MakerNote value's offset relative to the TIFF
|
|
31
|
+
* header, for the maker note readers.
|
|
32
|
+
*/
|
|
25
33
|
function read(
|
|
26
34
|
dataView,
|
|
27
35
|
tiffHeaderOffset,
|
|
@@ -33,15 +41,16 @@ function read(
|
|
|
33
41
|
readThumbnailIfd = undefined
|
|
34
42
|
) {
|
|
35
43
|
const byteOrder = ByteOrder.getByteOrder(dataView, tiffHeaderOffset);
|
|
36
|
-
|
|
44
|
+
const valueOffsets = {};
|
|
45
|
+
let tags = read0thIfd(dataView, tiffHeaderOffset, byteOrder, includeUnknown, computed, tagFilter, valueBudget, tagNames, readThumbnailIfd, valueOffsets);
|
|
37
46
|
for (let i = 0; i < SUB_IFDS.length; i++) {
|
|
38
|
-
tags = readSubIfd(SUB_IFDS[i], tags, dataView, tiffHeaderOffset, byteOrder, includeUnknown, computed, tagFilter, valueBudget, tagNames);
|
|
47
|
+
tags = readSubIfd(SUB_IFDS[i], tags, dataView, tiffHeaderOffset, byteOrder, includeUnknown, computed, tagFilter, valueBudget, tagNames, valueOffsets);
|
|
39
48
|
}
|
|
40
49
|
|
|
41
|
-
return {tags, byteOrder};
|
|
50
|
+
return {tags, byteOrder, makerNoteOffset: valueOffsets.MakerNote};
|
|
42
51
|
}
|
|
43
52
|
|
|
44
|
-
function read0thIfd(dataView, tiffHeaderOffset, byteOrder, includeUnknown, computed, tagFilter, valueBudget, tagNames, readThumbnailIfd) {
|
|
53
|
+
function read0thIfd(dataView, tiffHeaderOffset, byteOrder, includeUnknown, computed, tagFilter, valueBudget, tagNames, readThumbnailIfd, valueOffsets) {
|
|
45
54
|
const ifdOffset = get0thIfdOffset(dataView, tiffHeaderOffset, byteOrder);
|
|
46
55
|
if (ifdOffset === undefined) {
|
|
47
56
|
return {};
|
|
@@ -58,11 +67,12 @@ function read0thIfd(dataView, tiffHeaderOffset, byteOrder, includeUnknown, compu
|
|
|
58
67
|
'exif',
|
|
59
68
|
valueBudget,
|
|
60
69
|
tagNames,
|
|
61
|
-
readThumbnailIfd
|
|
70
|
+
readThumbnailIfd,
|
|
71
|
+
valueOffsets
|
|
62
72
|
);
|
|
63
73
|
}
|
|
64
74
|
|
|
65
|
-
function readSubIfd(subIfd, tags, dataView, tiffHeaderOffset, byteOrder, includeUnknown, computed, tagFilter, valueBudget, tagNames) {
|
|
75
|
+
function readSubIfd(subIfd, tags, dataView, tiffHeaderOffset, byteOrder, includeUnknown, computed, tagFilter, valueBudget, tagNames, valueOffsets) {
|
|
66
76
|
const pointerTag = tags[subIfd.pointerKey];
|
|
67
77
|
if (pointerTag === undefined) {
|
|
68
78
|
return tags;
|
|
@@ -86,7 +96,9 @@ function readSubIfd(subIfd, tags, dataView, tiffHeaderOffset, byteOrder, include
|
|
|
86
96
|
tagFilter,
|
|
87
97
|
'exif',
|
|
88
98
|
valueBudget,
|
|
89
|
-
tagNames
|
|
99
|
+
tagNames,
|
|
100
|
+
undefined,
|
|
101
|
+
valueOffsets
|
|
90
102
|
)
|
|
91
103
|
);
|
|
92
104
|
}
|
package/src/thumbnail.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
3
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
4
|
|
|
5
|
-
import {deferInit
|
|
5
|
+
import {deferInit} from './utils.js';
|
|
6
6
|
|
|
7
7
|
// https://exiftool.org/TagNames/EXIF.html#Compression
|
|
8
8
|
const COMPRESSION_JPEG = [6, 7, 99];
|
|
@@ -11,7 +11,7 @@ export default {
|
|
|
11
11
|
get,
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
function get(dataView, thumbnailTags, tiffHeaderOffset) {
|
|
14
|
+
function get(dataView, thumbnailTags, tiffHeaderOffset, getBase64Image) {
|
|
15
15
|
if (hasJpegThumbnail(thumbnailTags)) {
|
|
16
16
|
const offset = tiffHeaderOffset + thumbnailTags.JPEGInterchangeFormat.value;
|
|
17
17
|
const length = thumbnailTags.JPEGInterchangeFormatLength.value;
|
|
@@ -20,9 +20,11 @@ function get(dataView, thumbnailTags, tiffHeaderOffset) {
|
|
|
20
20
|
thumbnailTags.type = 'image/jpeg';
|
|
21
21
|
const byteOffset = dataView.byteOffset;
|
|
22
22
|
thumbnailTags.image = dataView.buffer.slice(byteOffset + offset, byteOffset + offset + length);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
if (getBase64Image) {
|
|
24
|
+
deferInit(thumbnailTags, 'base64', function () {
|
|
25
|
+
return getBase64Image(this.image);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
|