exifreader 4.22.0 → 4.23.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.22.0",
3
+ "version": "4.23.1",
4
4
  "description": "Library that parses Exif metadata in images.",
5
5
  "author": "Mattias Wallander <mattias@wallander.eu>",
6
6
  "repository": {
@@ -29,13 +29,13 @@
29
29
  "@babel/preset-env": "^7.23.2",
30
30
  "@babel/register": "^7.22.15",
31
31
  "@types/node": "^18.11.9",
32
- "babel-loader": "^8.2.5",
32
+ "babel-loader": "^9.1.3",
33
33
  "babel-plugin-rewire": "^1.2.0",
34
34
  "chai": "^4.3.10",
35
35
  "cross-env": "^7.0.3",
36
36
  "cypress": "^13.3.2",
37
37
  "eslint": "^8.52.0",
38
- "eslint-plugin-cypress": "^2.15.1",
38
+ "eslint-plugin-cypress": "^3.0.2",
39
39
  "husky": "^9.0.11",
40
40
  "mocha": "^10.2.0",
41
41
  "npm-run-all": "^4.1.5",
@@ -46,7 +46,7 @@
46
46
  "typescript": "^5.2.2",
47
47
  "webpack": "^5.89.0",
48
48
  "webpack-cli": "^5.1.4",
49
- "webpack-dev-server": "^4.15.1"
49
+ "webpack-dev-server": "^5.0.4"
50
50
  },
51
51
  "scripts": {
52
52
  "build": "node bin/build.js",
@@ -136,6 +136,8 @@ function getVariableSizedValue(dataView, offset, size) {
136
136
  return dataView.getUint32(offset);
137
137
  }
138
138
  if (size === 8) {
139
+ // eslint-disable-next-line no-console
140
+ console.warn('This file uses an 8-bit offset which is currently not supported by ExifReader. Contact the maintainer to get it fixed.');
139
141
  return get64BitValue(dataView, offset);
140
142
  }
141
143
  return 0;
@@ -207,7 +207,8 @@ function findMetaBox(dataView) {
207
207
  function findExifOffset(dataView, metaBox) {
208
208
  try {
209
209
  const exifItemId = findIinfExifItemId(metaBox).itemId;
210
- const exifOffset = findIlocItem(metaBox, exifItemId).extents[0].extentOffset;
210
+ const ilocItem = findIlocItem(metaBox, exifItemId);
211
+ const exifOffset = ilocItem.baseOffset + ilocItem.extents[0].extentOffset;
211
212
  return getTiffHeaderOffset(dataView, exifOffset);
212
213
  } catch (error) {
213
214
  return undefined;
@@ -232,11 +233,12 @@ function getTiffHeaderOffset(dataView, exifOffset) {
232
233
  function findXmpChunks(metaBox) {
233
234
  try {
234
235
  const xmpItemId = findIinfXmpItemId(metaBox).itemId;
235
- const ilocItem = findIlocItem(metaBox, xmpItemId).extents[0];
236
+ const ilocItem = findIlocItem(metaBox, xmpItemId);
237
+ const ilocItemExtent = findIlocItem(metaBox, xmpItemId).extents[0];
236
238
  return [
237
239
  {
238
- dataOffset: ilocItem.extentOffset,
239
- length: ilocItem.extentLength,
240
+ dataOffset: ilocItem.baseOffset + ilocItemExtent.extentOffset,
241
+ length: ilocItemExtent.extentLength,
240
242
  }
241
243
  ];
242
244
  } catch (error) {
@@ -10,6 +10,7 @@ import Heic from './image-header-heic.js';
10
10
  import Avif from './image-header-avif.js';
11
11
  import Webp from './image-header-webp.js';
12
12
  import Gif from './image-header-gif.js';
13
+ import Xml from './xml.js';
13
14
  import {objectAssign} from './utils.js';
14
15
 
15
16
  export default {
@@ -45,6 +46,10 @@ function parseAppMarkers(dataView, async) {
45
46
  return addFileType(Gif.findOffsets(dataView), 'gif', 'GIF');
46
47
  }
47
48
 
49
+ if (Constants.USE_XMP && Xml.isXMLFile(dataView)) {
50
+ return addFileType(Xml.findOffsets(dataView), 'xml', 'XML');
51
+ }
52
+
48
53
  throw new Error('Invalid image format');
49
54
  }
50
55
 
package/src/xml.js ADDED
@@ -0,0 +1,25 @@
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 {getStringFromDataView} from './utils.js';
6
+
7
+ export default {
8
+ isXMLFile,
9
+ findOffsets
10
+ };
11
+
12
+ const XML_MARKER_OFFSET = 0;
13
+ const XML_MARKER = '<?xpacket begin';
14
+
15
+ function isXMLFile(dataView) {
16
+ return !!dataView && getStringFromDataView(dataView, XML_MARKER_OFFSET, XML_MARKER.length) === XML_MARKER;
17
+ }
18
+
19
+ function findOffsets(dataView) {
20
+ const xmpChunks = [];
21
+ xmpChunks.push({dataOffset: XML_MARKER_OFFSET, length: dataView.byteLength});
22
+ return {
23
+ xmpChunks,
24
+ };
25
+ }