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
package/src/file-loaders.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
/* global Buffer */
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import {getByteString, getHexDigitValue, isArrayBufferViewLike} from './utils.js';
|
|
12
12
|
import NodeRequire from './node-require.js';
|
|
13
13
|
|
|
14
14
|
export const HTTP_STATUS_OK = 200;
|
|
@@ -59,6 +59,79 @@ export function loadFile(filename, options) {
|
|
|
59
59
|
return readLocalFileRange(filename, range).then((r) => r.buffer);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
export function dataUriToBuffer(dataUri) {
|
|
63
|
+
const commaIndex = dataUri.indexOf(',');
|
|
64
|
+
const header = dataUri.substring(0, commaIndex);
|
|
65
|
+
const data = dataUri.substring(commaIndex + 1);
|
|
66
|
+
|
|
67
|
+
if (header.indexOf(';base64') !== -1) {
|
|
68
|
+
const base64 = percentDecodeBase64Payload(data);
|
|
69
|
+
if (typeof atob !== 'undefined') {
|
|
70
|
+
return binaryStringToArrayBuffer(atob(base64));
|
|
71
|
+
}
|
|
72
|
+
if (typeof Buffer === 'undefined') {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
if (typeof Buffer.from !== 'undefined') {
|
|
76
|
+
return Buffer.from(base64, 'base64');
|
|
77
|
+
}
|
|
78
|
+
return new Buffer(base64, 'base64');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return percentDecodeToBytes(data).buffer;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// WHATWG data: URL processing percent-decodes the body before the forgiving-base64 decode.
|
|
85
|
+
// A non-ASCII payload can never be valid base64, so it goes to the decoder unchanged.
|
|
86
|
+
function percentDecodeBase64Payload(data) {
|
|
87
|
+
if (data.indexOf('%') === -1 || /[\u0080-\uffff]/.test(data)) {
|
|
88
|
+
return data;
|
|
89
|
+
}
|
|
90
|
+
return getByteString(percentDecodeToBytes(data));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function binaryStringToArrayBuffer(string) {
|
|
94
|
+
const bytes = new Uint8Array(string.length);
|
|
95
|
+
for (let i = 0; i < string.length; i++) {
|
|
96
|
+
bytes[i] = string.charCodeAt(i);
|
|
97
|
+
}
|
|
98
|
+
return bytes.buffer;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// WHATWG URL "string percent-decode" (used for data: URLs, RFC 2397): UTF-8 encode, then each %XX is one byte.
|
|
102
|
+
function percentDecodeToBytes(string) {
|
|
103
|
+
const byteString = /[\u0080-\uffff]/.test(string) ? unescape(encodeURIComponent(string)) : string;
|
|
104
|
+
const bytes = new Uint8Array(byteString.length - 2 * countPercentEscapes(byteString));
|
|
105
|
+
let byteIndex = 0;
|
|
106
|
+
for (let i = 0; i < byteString.length; i++) {
|
|
107
|
+
if (isPercentEscape(byteString, i)) {
|
|
108
|
+
bytes[byteIndex++] = getHexDigitValue(byteString.charCodeAt(i + 1)) * 16 + getHexDigitValue(byteString.charCodeAt(i + 2));
|
|
109
|
+
i += 2;
|
|
110
|
+
} else {
|
|
111
|
+
bytes[byteIndex++] = byteString.charCodeAt(i);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return bytes;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function countPercentEscapes(byteString) {
|
|
118
|
+
let count = 0;
|
|
119
|
+
for (let i = 0; i < byteString.length; i++) {
|
|
120
|
+
if (isPercentEscape(byteString, i)) {
|
|
121
|
+
count++;
|
|
122
|
+
i += 2;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return count;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function isPercentEscape(byteString, index) {
|
|
129
|
+
return byteString.charCodeAt(index) === 0x25
|
|
130
|
+
&& index + 2 < byteString.length
|
|
131
|
+
&& getHexDigitValue(byteString.charCodeAt(index + 1)) !== -1
|
|
132
|
+
&& getHexDigitValue(byteString.charCodeAt(index + 2)) !== -1;
|
|
133
|
+
}
|
|
134
|
+
|
|
62
135
|
/**
|
|
63
136
|
* Browser `File` equivalent of `loadFile`. Used by the numeric-`length`
|
|
64
137
|
* code path in `load()`.
|
package/src/file-tags.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
|
|
5
|
+
import {getShortAt, getByteAt} from './types.js';
|
|
6
6
|
|
|
7
7
|
export default {
|
|
8
8
|
read
|
|
@@ -22,7 +22,7 @@ function read(dataView, fileDataOffset) {
|
|
|
22
22
|
|
|
23
23
|
function getLength(dataView, fileDataOffset) {
|
|
24
24
|
// The declared length is untrusted, so bound it by the bytes present.
|
|
25
|
-
return Math.min(
|
|
25
|
+
return Math.min(getShortAt(dataView, fileDataOffset), dataView.byteLength - fileDataOffset);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
function getDataPrecision(dataView, fileDataOffset, length) {
|
|
@@ -33,7 +33,7 @@ function getDataPrecision(dataView, fileDataOffset, length) {
|
|
|
33
33
|
return undefined;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
const value =
|
|
36
|
+
const value = getByteAt(dataView, fileDataOffset + OFFSET);
|
|
37
37
|
return {
|
|
38
38
|
value,
|
|
39
39
|
description: '' + value
|
|
@@ -48,7 +48,7 @@ function getImageHeight(dataView, fileDataOffset, length) {
|
|
|
48
48
|
return undefined;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
const value =
|
|
51
|
+
const value = getShortAt(dataView, fileDataOffset + OFFSET);
|
|
52
52
|
return {
|
|
53
53
|
value,
|
|
54
54
|
description: `${value}px`
|
|
@@ -63,7 +63,7 @@ function getImageWidth(dataView, fileDataOffset, length) {
|
|
|
63
63
|
return undefined;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
const value =
|
|
66
|
+
const value = getShortAt(dataView, fileDataOffset + OFFSET);
|
|
67
67
|
return {
|
|
68
68
|
value,
|
|
69
69
|
description: `${value}px`
|
|
@@ -78,7 +78,7 @@ function getNumberOfColorComponents(dataView, fileDataOffset, length) {
|
|
|
78
78
|
return undefined;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
const value =
|
|
81
|
+
const value = getByteAt(dataView, fileDataOffset + OFFSET);
|
|
82
82
|
return {
|
|
83
83
|
value,
|
|
84
84
|
description: '' + value
|
|
@@ -98,9 +98,9 @@ function getSubsampling(dataView, fileDataOffset, numberOfColorComponents, lengt
|
|
|
98
98
|
for (let i = 0; i < numberOfColorComponents; i++) {
|
|
99
99
|
const componentOffset = fileDataOffset + OFFSET + i * 3;
|
|
100
100
|
components.push([
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
getByteAt(dataView, componentOffset),
|
|
102
|
+
getByteAt(dataView, componentOffset + 1),
|
|
103
|
+
getByteAt(dataView, componentOffset + 2)
|
|
104
104
|
]);
|
|
105
105
|
}
|
|
106
106
|
|
package/src/image-header.js
CHANGED
|
@@ -2,16 +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
|
|
6
|
-
import Tiff from './image-header-tiff.js';
|
|
7
|
-
import Jpeg from './image-header-jpeg.js';
|
|
8
|
-
import Png from './image-header-png.js';
|
|
9
|
-
import Heic from './image-header-heic.js';
|
|
10
|
-
import Avif from './image-header-avif.js';
|
|
11
|
-
import Jxl from './image-header-jxl.js';
|
|
12
|
-
import Webp from './image-header-webp.js';
|
|
13
|
-
import Gif from './image-header-gif.js';
|
|
14
|
-
import Xml from './xml.js';
|
|
5
|
+
import {UnsupportedFormatError} from './unsupported-format-error.js';
|
|
15
6
|
|
|
16
7
|
export default {
|
|
17
8
|
parseAppMarkers
|
|
@@ -25,50 +16,25 @@ export default {
|
|
|
25
16
|
* each block's bytes sit in the file. The result then gains `ranges`, a
|
|
26
17
|
* list of `{block, start, end}` in file order, and `truncated`, true when
|
|
27
18
|
* the finder never reached the end of the file's metadata.
|
|
19
|
+
* @param {Array<{header: {fileType: {value: string, description: string}, detect: function, find: function}}>} formats
|
|
20
|
+
* The composed formats in detection order; the first whose `detect`
|
|
21
|
+
* matches runs its `find`.
|
|
28
22
|
* @returns {{fileType: {value: string, description: string}, blocks: Array<Object>, ranges: (Array<Object>|undefined), truncated: (boolean|undefined)}}
|
|
29
23
|
* The blocks the finder found, each `{kind, ...payload}`.
|
|
30
|
-
* @throws {
|
|
24
|
+
* @throws {UnsupportedFormatError} When the data view is not a recognized
|
|
25
|
+
* image format.
|
|
31
26
|
*/
|
|
32
|
-
function parseAppMarkers(dataView, includeRanges) {
|
|
27
|
+
function parseAppMarkers(dataView, includeRanges, formats) {
|
|
33
28
|
const ranges = includeRanges ? [] : undefined;
|
|
34
29
|
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
for (let i = 0; i < formats.length; i++) {
|
|
31
|
+
const header = formats[i].header;
|
|
32
|
+
if (header.detect(dataView)) {
|
|
33
|
+
return finalize(header.find(dataView, ranges), header.fileType.value, header.fileType.description, ranges);
|
|
34
|
+
}
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
return finalize(Jpeg.findJpegOffsets(dataView, ranges), 'jpeg', 'JPEG', ranges);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (Constants.USE_PNG && Png.isPngFile(dataView)) {
|
|
44
|
-
return finalize(Png.findPngOffsets(dataView, ranges), 'png', 'PNG', ranges);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (Constants.USE_HEIC && Heic.isHeicFile(dataView)) {
|
|
48
|
-
return finalize(Heic.findHeicOffsets(dataView, ranges), 'heic', 'HEIC', ranges);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (Constants.USE_AVIF && Avif.isAvifFile(dataView)) {
|
|
52
|
-
return finalize(Avif.findAvifOffsets(dataView, ranges), 'avif', 'AVIF', ranges);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (Constants.USE_JXL && Jxl.isJxlFile(dataView)) {
|
|
56
|
-
return finalize(Jxl.findJxlOffsets(dataView, ranges), 'jxl', 'JPEG XL', ranges);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (Constants.USE_WEBP && Webp.isWebpFile(dataView)) {
|
|
60
|
-
return finalize(Webp.findOffsets(dataView, ranges), 'webp', 'WebP', ranges);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (Constants.USE_GIF && Gif.isGifFile(dataView)) {
|
|
64
|
-
return finalize(Gif.findOffsets(dataView, ranges), 'gif', 'GIF', ranges);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (Constants.USE_XMP && Xml.isXMLFile(dataView)) {
|
|
68
|
-
return finalize(Xml.findOffsets(dataView, ranges), 'xml', 'XML', ranges);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
throw new Error('Invalid image format');
|
|
37
|
+
throw new UnsupportedFormatError('Invalid image format');
|
|
72
38
|
}
|
|
73
39
|
|
|
74
40
|
function finalize(blocks, fileType, fileTypeDescription, ranges) {
|
|
@@ -0,0 +1,334 @@
|
|
|
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
|
+
import {getStringValue} from './tag-names-utils.js';
|
|
6
|
+
|
|
7
|
+
export function getModelVersionDescription(value) {
|
|
8
|
+
return ((value[0] << 8) + value[1]).toString();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function getFileFormatDescription(value) {
|
|
12
|
+
return ((value[0] << 8) + value[1]).toString();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function getFileFormatVersionDescription(value) {
|
|
16
|
+
return ((value[0] << 8) + value[1]).toString();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getARMIdentifierDescription(value) {
|
|
20
|
+
return ((value[0] << 8) + value[1]).toString();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function getARMVersionDescription(value) {
|
|
24
|
+
return ((value[0] << 8) + value[1]).toString();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function getRecordVersionDescription(value) {
|
|
28
|
+
return ((value[0] << 8) + value[1]).toString();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function getEditorialUpdateDescription(value) {
|
|
32
|
+
if (getStringValue(value) === '01') {
|
|
33
|
+
return 'Additional Language';
|
|
34
|
+
}
|
|
35
|
+
return 'Unknown';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function getSubjectReferenceDescription(value) {
|
|
39
|
+
const parts = getStringValue(value).split(':');
|
|
40
|
+
return parts[2] + (parts[3] ? '/' + parts[3] : '') + (parts[4] ? '/' + parts[4] : '');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function getActionAdvisedDescription(value) {
|
|
44
|
+
const string = getStringValue(value);
|
|
45
|
+
if (string === '01') {
|
|
46
|
+
return 'Object Kill';
|
|
47
|
+
} else if (string === '02') {
|
|
48
|
+
return 'Object Replace';
|
|
49
|
+
} else if (string === '03') {
|
|
50
|
+
return 'Object Append';
|
|
51
|
+
} else if (string === '04') {
|
|
52
|
+
return 'Object Reference';
|
|
53
|
+
}
|
|
54
|
+
return 'Unknown';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function getObjectCycleDescription(value) {
|
|
58
|
+
const string = getStringValue(value);
|
|
59
|
+
if (string === 'a') {
|
|
60
|
+
return 'morning';
|
|
61
|
+
} else if (string === 'p') {
|
|
62
|
+
return 'evening';
|
|
63
|
+
} else if (string === 'b') {
|
|
64
|
+
return 'both';
|
|
65
|
+
}
|
|
66
|
+
return 'Unknown';
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function getRasterizedCaptionDescription(value) {
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function getImageOrientationDescription(value) {
|
|
74
|
+
const string = getStringValue(value);
|
|
75
|
+
if (string === 'P') {
|
|
76
|
+
return 'Portrait';
|
|
77
|
+
} else if (string === 'L') {
|
|
78
|
+
return 'Landscape';
|
|
79
|
+
} else if (string === 'S') {
|
|
80
|
+
return 'Square';
|
|
81
|
+
}
|
|
82
|
+
return 'Unknown';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function getAudioTypeDescription(value) {
|
|
86
|
+
const stringValue = getStringValue(value);
|
|
87
|
+
const character0 = stringValue.charAt(0);
|
|
88
|
+
const character1 = stringValue.charAt(1);
|
|
89
|
+
let description = '';
|
|
90
|
+
|
|
91
|
+
if (character0 === '1') {
|
|
92
|
+
description += 'Mono';
|
|
93
|
+
} else if (character0 === '2') {
|
|
94
|
+
description += 'Stereo';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (character1 === 'A') {
|
|
98
|
+
description += ', actuality';
|
|
99
|
+
} else if (character1 === 'C') {
|
|
100
|
+
description += ', question and answer session';
|
|
101
|
+
} else if (character1 === 'M') {
|
|
102
|
+
description += ', music, transmitted by itself';
|
|
103
|
+
} else if (character1 === 'Q') {
|
|
104
|
+
description += ', response to a question';
|
|
105
|
+
} else if (character1 === 'R') {
|
|
106
|
+
description += ', raw sound';
|
|
107
|
+
} else if (character1 === 'S') {
|
|
108
|
+
description += ', scener';
|
|
109
|
+
} else if (character1 === 'V') {
|
|
110
|
+
description += ', voicer';
|
|
111
|
+
} else if (character1 === 'W') {
|
|
112
|
+
description += ', wrap';
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (description !== '') {
|
|
116
|
+
return description;
|
|
117
|
+
}
|
|
118
|
+
return stringValue;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function getAudioSamplingRateDescription(value) {
|
|
122
|
+
return parseInt(getStringValue(value), 10) + ' Hz';
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function getAudioSamplingResolutionDescription(value) {
|
|
126
|
+
const bits = parseInt(getStringValue(value), 10);
|
|
127
|
+
return bits + (bits === 1 ? ' bit' : ' bits');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function getAudioDurationDescription(value) {
|
|
131
|
+
const duration = getStringValue(value);
|
|
132
|
+
if (duration.length >= 6) {
|
|
133
|
+
return duration.substr(0, 2) + ':' + duration.substr(2, 2) + ':' + duration.substr(4, 2);
|
|
134
|
+
}
|
|
135
|
+
return duration;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function getRecord2DestinationDescription(value) {
|
|
139
|
+
if (value.length === 2) {
|
|
140
|
+
const intValue = getPreviewNumber(value);
|
|
141
|
+
if (intValue === 0) {
|
|
142
|
+
return 'No ObjectData';
|
|
143
|
+
} else if (intValue === 1) {
|
|
144
|
+
return 'IPTC-NAA Digital Newsphoto Parameter Record';
|
|
145
|
+
} else if (intValue === 2) {
|
|
146
|
+
return 'IPTC7901 Recommended Message Format';
|
|
147
|
+
} else if (intValue === 3) {
|
|
148
|
+
return 'Tagged Image File Format (Adobe/Aldus Image data)';
|
|
149
|
+
} else if (intValue === 4) {
|
|
150
|
+
return 'Illustrator (Adobe Graphics data)';
|
|
151
|
+
} else if (intValue === 5) {
|
|
152
|
+
return 'AppleSingle (Apple Computer Inc)';
|
|
153
|
+
} else if (intValue === 6) {
|
|
154
|
+
return 'NAA 89-3 (ANPA 1312)';
|
|
155
|
+
} else if (intValue === 7) {
|
|
156
|
+
return 'MacBinary II';
|
|
157
|
+
} else if (intValue === 8) {
|
|
158
|
+
return 'IPTC Unstructured Character Oriented File Format (UCOFF)';
|
|
159
|
+
} else if (intValue === 9) {
|
|
160
|
+
return 'United Press International ANPA 1312 variant';
|
|
161
|
+
} else if (intValue === 10) {
|
|
162
|
+
return 'United Press International Down-Load Message';
|
|
163
|
+
} else if (intValue === 11) {
|
|
164
|
+
return 'JPEG File Interchange (JFIF)';
|
|
165
|
+
} else if (intValue === 12) {
|
|
166
|
+
return 'Photo-CD Image-Pac (Eastman Kodak)';
|
|
167
|
+
} else if (intValue === 13) {
|
|
168
|
+
return 'Microsoft Bit Mapped Graphics File [*.BMP]';
|
|
169
|
+
} else if (intValue === 14) {
|
|
170
|
+
return 'Digital Audio File [*.WAV] (Microsoft & Creative Labs)';
|
|
171
|
+
} else if (intValue === 15) {
|
|
172
|
+
return 'Audio plus Moving Video [*.AVI] (Microsoft)';
|
|
173
|
+
} else if (intValue === 16) {
|
|
174
|
+
return 'PC DOS/Windows Executable Files [*.COM][*.EXE]';
|
|
175
|
+
} else if (intValue === 17) {
|
|
176
|
+
return 'Compressed Binary File [*.ZIP] (PKWare Inc)';
|
|
177
|
+
} else if (intValue === 18) {
|
|
178
|
+
return 'Audio Interchange File Format AIFF (Apple Computer Inc)';
|
|
179
|
+
} else if (intValue === 19) {
|
|
180
|
+
return 'RIFF Wave (Microsoft Corporation)';
|
|
181
|
+
} else if (intValue === 20) {
|
|
182
|
+
return 'Freehand (Macromedia/Aldus)';
|
|
183
|
+
} else if (intValue === 21) {
|
|
184
|
+
return 'Hypertext Markup Language "HTML" (The Internet Society)';
|
|
185
|
+
} else if (intValue === 22) {
|
|
186
|
+
return 'MPEG 2 Audio Layer 2 (Musicom), ISO/IEC';
|
|
187
|
+
} else if (intValue === 23) {
|
|
188
|
+
return 'MPEG 2 Audio Layer 3, ISO/IEC';
|
|
189
|
+
} else if (intValue === 24) {
|
|
190
|
+
return 'Portable Document File (*.PDF) Adobe';
|
|
191
|
+
} else if (intValue === 25) {
|
|
192
|
+
return 'News Industry Text Format (NITF)';
|
|
193
|
+
} else if (intValue === 26) {
|
|
194
|
+
return 'Tape Archive (*.TAR)';
|
|
195
|
+
} else if (intValue === 27) {
|
|
196
|
+
return 'Tidningarnas Telegrambyrå NITF version (TTNITF DTD)';
|
|
197
|
+
} else if (intValue === 28) {
|
|
198
|
+
return 'Ritzaus Bureau NITF version (RBNITF DTD)';
|
|
199
|
+
} else if (intValue === 29) {
|
|
200
|
+
return 'Corel Draw [*.CDR]';
|
|
201
|
+
}
|
|
202
|
+
return `Unknown format ${intValue}`;
|
|
203
|
+
}
|
|
204
|
+
return getStringValue(value);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export function getObjectDataPreviewFileFormatVersionDescription(value, tags) {
|
|
208
|
+
// Format ID, Version ID, Version Description
|
|
209
|
+
const formatVersions = {
|
|
210
|
+
0: {0: '1'},
|
|
211
|
+
1: {1: '1', 2: '2', 3: '3', 4: '4'},
|
|
212
|
+
2: {4: '4'},
|
|
213
|
+
3: {1: '5.0', 2: '6.0'},
|
|
214
|
+
4: {1: '1.40'},
|
|
215
|
+
5: {1: '2'},
|
|
216
|
+
6: {1: '1'},
|
|
217
|
+
11: {1: '1.02'},
|
|
218
|
+
20: {1: '3.1', 2: '4.0', 3: '5.0', 4: '5.5'},
|
|
219
|
+
21: {2: '2.0'}
|
|
220
|
+
};
|
|
221
|
+
const version = getPreviewNumber(value);
|
|
222
|
+
|
|
223
|
+
if (tags['ObjectData Preview File Format']) {
|
|
224
|
+
const format = getPreviewNumber(tags['ObjectData Preview File Format'].value);
|
|
225
|
+
if (Object.prototype.hasOwnProperty.call(formatVersions, format)
|
|
226
|
+
&& Object.prototype.hasOwnProperty.call(formatVersions[format], version)) {
|
|
227
|
+
return formatVersions[format][version];
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const versionNumber = getBinaryNumber(value);
|
|
232
|
+
return versionNumber === null ? getStringValue(value) : String(versionNumber);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export function getSizeModeDescription(value) {
|
|
236
|
+
return (value[0]).toString();
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export function getMaxSubfileSizeDescription(value) {
|
|
240
|
+
let n = 0;
|
|
241
|
+
for (let i = 0; i < value.length; i++) {
|
|
242
|
+
n = (n << 8) + value[i];
|
|
243
|
+
}
|
|
244
|
+
return n.toString();
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export function getObjectDataSizeAnnouncedDescription(value) {
|
|
248
|
+
let n = 0;
|
|
249
|
+
for (let i = 0; i < value.length; i++) {
|
|
250
|
+
n = (n << 8) + value[i];
|
|
251
|
+
}
|
|
252
|
+
return n.toString();
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export function getMaximumObjectDataSizeDescription(value) {
|
|
256
|
+
let n = 0;
|
|
257
|
+
for (let i = 0; i < value.length; i++) {
|
|
258
|
+
n = (n << 8) + value[i];
|
|
259
|
+
}
|
|
260
|
+
return n.toString();
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export function getCreationDate(value) {
|
|
264
|
+
const date = getStringValue(value);
|
|
265
|
+
|
|
266
|
+
if (date.length >= 8) {
|
|
267
|
+
return date.substr(0, 4) + '-' + date.substr(4, 2) + '-' + date.substr(6, 2);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return date;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export function getCreationTime(value) {
|
|
274
|
+
const time = getStringValue(value);
|
|
275
|
+
let parsedTime = time;
|
|
276
|
+
|
|
277
|
+
if (time.length >= 6) {
|
|
278
|
+
parsedTime = time.substr(0, 2) + ':' + time.substr(2, 2) + ':' + time.substr(4, 2);
|
|
279
|
+
if (time.length === 11) {
|
|
280
|
+
parsedTime += time.substr(6, 1) + time.substr(7, 2) + ':' + time.substr(9, 2);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return parsedTime;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export function getEncodingName(value) {
|
|
288
|
+
const string = getStringValue(value);
|
|
289
|
+
if (string === '\x1b%G') {
|
|
290
|
+
return 'UTF-8';
|
|
291
|
+
} else if (string === '\x1b%5') {
|
|
292
|
+
return 'Windows-1252';
|
|
293
|
+
} else if (string === '\x1b%/G') {
|
|
294
|
+
return 'UTF-8 Level 1';
|
|
295
|
+
} else if (string === '\x1b%/H') {
|
|
296
|
+
return 'UTF-8 Level 2';
|
|
297
|
+
} else if (string === '\x1b%/I') {
|
|
298
|
+
return 'UTF-8 Level 3';
|
|
299
|
+
} else if (string === '\x1B/A') {
|
|
300
|
+
return 'ISO-8859-1';
|
|
301
|
+
} else if (string === '\x1B/B') {
|
|
302
|
+
return 'ISO-8859-2';
|
|
303
|
+
} else if (string === '\x1B/C') {
|
|
304
|
+
return 'ISO-8859-3';
|
|
305
|
+
} else if (string === '\x1B/D') {
|
|
306
|
+
return 'ISO-8859-4';
|
|
307
|
+
} else if (string === '\x1B/@') {
|
|
308
|
+
return 'ISO-8859-5';
|
|
309
|
+
} else if (string === '\x1B/G') {
|
|
310
|
+
return 'ISO-8859-6';
|
|
311
|
+
} else if (string === '\x1B/F') {
|
|
312
|
+
return 'ISO-8859-7';
|
|
313
|
+
} else if (string === '\x1B/H') {
|
|
314
|
+
return 'ISO-8859-8';
|
|
315
|
+
}
|
|
316
|
+
return 'Unknown';
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// IIM stores 2:200 and 2:201 as 2-octet binary; two ASCII digits are the text form.
|
|
320
|
+
function getPreviewNumber(value) {
|
|
321
|
+
const number = getBinaryNumber(value);
|
|
322
|
+
return number === null ? parseInt(getStringValue(value), 10) : number;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function getBinaryNumber(value) {
|
|
326
|
+
if (value.length !== 2 || (isAsciiDigit(value[0]) && isAsciiDigit(value[1]))) {
|
|
327
|
+
return null;
|
|
328
|
+
}
|
|
329
|
+
return (value[0] << 8) + value[1];
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function isAsciiDigit(octet) {
|
|
333
|
+
return octet >= 0x30 && octet <= 0x39;
|
|
334
|
+
}
|