exifreader 4.23.1 → 4.23.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exifreader",
3
- "version": "4.23.1",
3
+ "version": "4.23.2",
4
4
  "description": "Library that parses Exif metadata in images.",
5
5
  "author": "Mattias Wallander <mattias@wallander.eu>",
6
6
  "repository": {
@@ -452,6 +452,8 @@ export function loadView(
452
452
  readTags.__iptc ? readTags.__iptc : {},
453
453
  readTags
454
454
  );
455
+ delete tags.__exif;
456
+ delete tags.__iptc;
455
457
  }
456
458
  }
457
459
  }
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
  }
@@ -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 {
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).text();
161
+ return new Response(decompressedStream).arrayBuffer()
162
+ .then((buffer) => new TextDecoder(encoding).decode(buffer));
162
163
  }
163
164
  }
164
165
  if (compressionMethod !== undefined) {