exifreader 4.36.0 → 4.36.1

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.36.0",
3
+ "version": "4.36.1",
4
4
  "description": "Library that parses Exif metadata in images.",
5
5
  "author": "Mattias Wallander <mattias@wallander.eu>",
6
6
  "repository": {
@@ -12,6 +12,9 @@ export default {
12
12
  };
13
13
 
14
14
  function decode(encoding, tagValue) {
15
+ if (typeof tagValue === 'string') {
16
+ return decodeAsciiValue(tagValue);
17
+ }
15
18
  const Decoder = TextDecoder.get();
16
19
  if ((typeof Decoder !== 'undefined') && (encoding !== undefined)) {
17
20
  try {
package/src/utils.js CHANGED
@@ -165,5 +165,15 @@ export function decompress(dataView, compressionMethod, encoding, returnType = '
165
165
  if (compressionMethod !== undefined) {
166
166
  return Promise.reject(`Unknown compression method ${compressionMethod}.`);
167
167
  }
168
+
169
+ // handle uncompressed iTXT with proper encoding awareness
170
+ if (returnType === 'string') {
171
+ try {
172
+ return new TextDecoder(encoding).decode(dataView);
173
+ } catch (error) {
174
+ const bytes = new Uint8Array(dataView.buffer, dataView.byteOffset, dataView.byteLength);
175
+ return Array.from(bytes, (byte) => String.fromCharCode(byte)).join('');
176
+ }
177
+ }
168
178
  return dataView;
169
179
  }