exifreader 4.23.1 → 4.23.3
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/package.json +1 -1
- package/src/exif-reader.js +2 -0
- package/src/icc-tags.js +1 -1
- package/src/png-text-tags.js +8 -1
- package/src/tag-names-exif-ifd.js +5 -2
- package/src/utils.js +3 -2
package/package.json
CHANGED
package/src/exif-reader.js
CHANGED
package/src/icc-tags.js
CHANGED
|
@@ -35,7 +35,7 @@ function readCompressedIcc(dataView, iccData) {
|
|
|
35
35
|
return {};
|
|
36
36
|
}
|
|
37
37
|
const compressedDataView = new DataView(dataView.buffer.slice(iccData[0].offset, iccData[0].offset + iccData[0].length));
|
|
38
|
-
return decompress(compressedDataView, iccData[0].compressionMethod, 'dataview')
|
|
38
|
+
return decompress(compressedDataView, iccData[0].compressionMethod, 'utf-8', 'dataview')
|
|
39
39
|
.then(parseTags)
|
|
40
40
|
.catch(() => ({}));
|
|
41
41
|
}
|
package/src/png-text-tags.js
CHANGED
|
@@ -106,7 +106,7 @@ function getNameAndValue(dataView, offset, length, type, async) {
|
|
|
106
106
|
if (compressionMethod !== COMPRESSION_METHOD_NONE && !async) {
|
|
107
107
|
return {};
|
|
108
108
|
}
|
|
109
|
-
const decompressedValueChars = decompress(valueChars, compressionMethod);
|
|
109
|
+
const decompressedValueChars = decompress(valueChars, compressionMethod, getEncodingFromType(type));
|
|
110
110
|
if (decompressedValueChars instanceof Promise) {
|
|
111
111
|
return decompressedValueChars
|
|
112
112
|
.then((_decompressedValueChars) => constructTag(_decompressedValueChars, type, langChars, keywordChars))
|
|
@@ -142,6 +142,13 @@ function moveToNextState(type, parsingState) {
|
|
|
142
142
|
return STATE_TEXT;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
function getEncodingFromType(type) {
|
|
146
|
+
if (type === TYPE_TEXT || type === TYPE_ZTXT) {
|
|
147
|
+
return 'latin1';
|
|
148
|
+
}
|
|
149
|
+
return 'utf-8';
|
|
150
|
+
}
|
|
151
|
+
|
|
145
152
|
function constructTag(valueChars, type, langChars, keywordChars) {
|
|
146
153
|
const value = getValue(valueChars);
|
|
147
154
|
return {
|
|
@@ -359,11 +359,14 @@ export default {
|
|
|
359
359
|
0xa432: {
|
|
360
360
|
'name': 'LensSpecification',
|
|
361
361
|
'description': (value) => {
|
|
362
|
-
const
|
|
362
|
+
const focalLengthFrom = parseFloat((value[0][0] / value[0][1]).toFixed(5));
|
|
363
|
+
const focalLengthTo = parseFloat((value[1][0] / value[1][1]).toFixed(5));
|
|
364
|
+
const focalLengths = `${focalLengthFrom}-${focalLengthTo} mm`;
|
|
363
365
|
if (value[3][1] === 0) {
|
|
364
366
|
return `${focalLengths} f/?`;
|
|
365
367
|
}
|
|
366
|
-
|
|
368
|
+
const maxAperture = 1 / ((value[2][1] / value[2][1]) / (value[3][0] / value[3][1]));
|
|
369
|
+
return `${focalLengths} f/${parseFloat(maxAperture.toFixed(5))}`;
|
|
367
370
|
}
|
|
368
371
|
},
|
|
369
372
|
0xa433: 'LensMake',
|
package/src/utils.js
CHANGED
|
@@ -150,7 +150,7 @@ export function strRepeat(string, num) {
|
|
|
150
150
|
export const COMPRESSION_METHOD_NONE = undefined;
|
|
151
151
|
export const COMPRESSION_METHOD_DEFLATE = 0;
|
|
152
152
|
|
|
153
|
-
export function decompress(dataView, compressionMethod, returnType = 'string') {
|
|
153
|
+
export function decompress(dataView, compressionMethod, encoding, returnType = 'string') {
|
|
154
154
|
if (compressionMethod === COMPRESSION_METHOD_DEFLATE) {
|
|
155
155
|
if (typeof DecompressionStream === 'function') {
|
|
156
156
|
const decompressionStream = new DecompressionStream('deflate');
|
|
@@ -158,7 +158,8 @@ export function decompress(dataView, compressionMethod, returnType = 'string') {
|
|
|
158
158
|
if (returnType === 'dataview') {
|
|
159
159
|
return new Response(decompressedStream).arrayBuffer().then((arrayBuffer) => new DataView(arrayBuffer));
|
|
160
160
|
}
|
|
161
|
-
return new Response(decompressedStream).
|
|
161
|
+
return new Response(decompressedStream).arrayBuffer()
|
|
162
|
+
.then((buffer) => new TextDecoder(encoding).decode(buffer));
|
|
162
163
|
}
|
|
163
164
|
}
|
|
164
165
|
if (compressionMethod !== undefined) {
|