exifreader 4.54.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 +398 -27
- 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/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/engine.js +50 -106
- package/src/errors.js +8 -2
- package/src/exif-reader.d.ts +8 -0
- package/src/exif-reader.js +112 -763
- package/src/file-loaders.js +74 -1
- package/src/file-tags.js +9 -9
- package/src/image-header.js +13 -47
- 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 +52 -192
- package/src/node-require.js +15 -2
- package/src/png-text-tags.js +5 -3
- package/src/tag-filter-config.js +24 -15
- package/src/tag-filter.js +15 -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 +28 -3
- package/src/tags-helpers.js +6 -2
- package/src/types.js +2 -0
- package/src/unsupported-format-error.js +21 -0
- package/src/utils.js +22 -85
- package/src/xmp-tag-names.js +42 -21
- 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
|
@@ -35,9 +35,9 @@ 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)) {
|
|
@@ -46,7 +46,7 @@ export function getVersionString(value) {
|
|
|
46
46
|
}
|
|
47
47
|
return getByteString(value);
|
|
48
48
|
}
|
|
49
|
-
return value;
|
|
49
|
+
return String(value);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/**
|
|
@@ -86,6 +86,31 @@ export function getTableDescription(table, value) {
|
|
|
86
86
|
return Object.prototype.hasOwnProperty.call(table, key) ? table[key] : 'Unknown';
|
|
87
87
|
}
|
|
88
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
|
+
|
|
89
114
|
export function getCalculatedGpsValue(value) {
|
|
90
115
|
return (value[0][0] / value[0][1]) + (value[1][0] / value[1][1]) / 60 + (value[2][0] / value[2][1]) / 3600;
|
|
91
116
|
}
|
package/src/tags-helpers.js
CHANGED
|
@@ -355,7 +355,7 @@ function readTag(
|
|
|
355
355
|
tagValue = getAsciiTagValue(tagValue, stringBudget);
|
|
356
356
|
}
|
|
357
357
|
|
|
358
|
-
let tagDescription = tagValue;
|
|
358
|
+
let tagDescription = getNumberAsString(tagValue);
|
|
359
359
|
|
|
360
360
|
if (tagNames[ifdType][tagCode] !== undefined) {
|
|
361
361
|
if ((tagNames[ifdType][tagCode]['name'] !== undefined) && (tagNames[ifdType][tagCode]['description'] !== undefined)) {
|
|
@@ -504,7 +504,11 @@ function getDescriptionFromTagValue(tagValue) {
|
|
|
504
504
|
if (tagValue instanceof Array) {
|
|
505
505
|
return tagValue.join(', ');
|
|
506
506
|
}
|
|
507
|
-
return tagValue;
|
|
507
|
+
return getNumberAsString(tagValue);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
function getNumberAsString(value) {
|
|
511
|
+
return typeof value === 'number' ? String(value) : value;
|
|
508
512
|
}
|
|
509
513
|
|
|
510
514
|
function getComputedTagValue(tagType, value) {
|
package/src/types.js
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
/**
|
|
6
|
+
* Thrown when no supported image format recognizes the input.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} message The error message.
|
|
9
|
+
*/
|
|
10
|
+
function UnsupportedFormatError(message) {
|
|
11
|
+
this.name = 'UnsupportedFormatError';
|
|
12
|
+
this.message = message;
|
|
13
|
+
// Defined, not assigned, to keep stack out of the enumerable keys.
|
|
14
|
+
Object.defineProperty(this, 'stack', {value: (new Error(message)).stack, writable: true, configurable: true});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
UnsupportedFormatError.prototype = Object.create(Error.prototype, {
|
|
18
|
+
constructor: {value: UnsupportedFormatError, writable: true, configurable: true}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export {UnsupportedFormatError};
|