exifreader 4.36.0 → 4.36.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.36.0",
3
+ "version": "4.36.2",
4
4
  "description": "Library that parses Exif metadata in images.",
5
5
  "author": "Mattias Wallander <mattias@wallander.eu>",
6
6
  "repository": {
@@ -45,7 +45,7 @@
45
45
  "string-replace-loader": "^3.1.0",
46
46
  "terser-webpack-plugin": "^5.3.10",
47
47
  "typescript": "^5.6.2",
48
- "webpack": "5.104.1",
48
+ "webpack": "5.105.2",
49
49
  "webpack-cli": "^5.1.4",
50
50
  "webpack-dev-server": "^5.0.4"
51
51
  },
@@ -63,6 +63,7 @@ const APP1_EXIF_IDENTIFIER = 'Exif';
63
63
  const APP1_XMP_IDENTIFIER = 'http://ns.adobe.com/xap/1.0/\x00';
64
64
  const APP1_XMP_EXTENDED_IDENTIFIER = 'http://ns.adobe.com/xmp/extension/\x00';
65
65
  const APP13_IPTC_IDENTIFIER = 'Photoshop 3.0';
66
+ const APP13_RESOURCE_BLOCK_IDENTIFIER = '8BIM';
66
67
 
67
68
  function isJpegFile(dataView) {
68
69
  return !!dataView && (dataView.byteLength >= MIN_JPEG_DATA_BUFFER_LENGTH) && (dataView.getUint16(0) === JPEG_ID);
@@ -271,10 +272,14 @@ function getExtendedXmpChunkDetails(appMarkerPosition, fieldLength) {
271
272
 
272
273
  function isApp13PhotoshopMarker(dataView, appMarkerPosition) {
273
274
  const markerIdLength = APP13_IPTC_IDENTIFIER.length;
275
+ const resourceIdentifierLength = APP13_RESOURCE_BLOCK_IDENTIFIER.length;
276
+ const resourceIdentifierOffset = appMarkerPosition + APP_ID_OFFSET
277
+ + markerIdLength + 1;
274
278
 
275
279
  return (dataView.getUint16(appMarkerPosition) === APP13_MARKER)
276
280
  && (getStringFromDataView(dataView, appMarkerPosition + APP_ID_OFFSET, markerIdLength) === APP13_IPTC_IDENTIFIER)
277
- && (dataView.getUint8(appMarkerPosition + APP_ID_OFFSET + markerIdLength) === 0x00);
281
+ && (dataView.getUint8(appMarkerPosition + APP_ID_OFFSET + markerIdLength) === 0x00)
282
+ && (getStringFromDataView(dataView, resourceIdentifierOffset, resourceIdentifierLength) === APP13_RESOURCE_BLOCK_IDENTIFIER);
278
283
  }
279
284
 
280
285
  function isAppMarker(dataView, appMarkerPosition) {
@@ -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
  }