image-js 1.6.1 → 1.6.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.
@@ -1,12 +1,10 @@
1
1
  /*
2
- * image-js v1.6.1
2
+ * image-js v1.6.2
3
3
  * Image processing and manipulation in JavaScript
4
4
  * https://github.com/image-js/image-js#readme
5
5
  *
6
6
  * Licensed under the MIT license.
7
7
  */
8
- import assert$1 from 'node:assert';
9
-
10
8
  function getDefaultExportFromCjs (x) {
11
9
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
12
10
  }
@@ -14083,7 +14081,7 @@ function getContourMoore(mask) {
14083
14081
  contour.push(currentPoint);
14084
14082
  }
14085
14083
  const next = findNextPoint(mask, currentPoint, backtrackPoint);
14086
- assert$1.ok(next, 'Next border point is undefined.');
14084
+ assert(next, 'Next border point is undefined.');
14087
14085
  backtrackPoint = next.prevPoint;
14088
14086
  currentPoint = next.currPoint;
14089
14087
  if (currentPoint.column === startingPoint.column && currentPoint.row === startingPoint.row) {
@@ -23800,7 +23798,7 @@ function getAffineTransform(source, destination, options = {}) {
23800
23798
  },
23801
23799
  maxRansacNbIterations,
23802
23800
  debug = false,
23803
- debugImagePath = `${import.meta.dirname}/montage.png`
23801
+ debugImagePath
23804
23802
  } = options;
23805
23803
  if (source.colorModel !== ImageColorModel.GREY) {
23806
23804
  source = source.grey();
@@ -23880,6 +23878,9 @@ function getAffineTransform(source, destination, options = {}) {
23880
23878
  }
23881
23879
  // create debug image
23882
23880
  if (debug) {
23881
+ if (!debugImagePath) {
23882
+ throw new RangeError('Debug image file path is not specified.');
23883
+ }
23883
23884
  const montage = new Montage(source, destination, {
23884
23885
  disposition: MontageDisposition.VERTICAL
23885
23886
  });
@@ -25053,10 +25054,27 @@ function decodeBmp(data) {
25053
25054
  }
25054
25055
  return new Image(decodedData.width, decodedData.height, {
25055
25056
  colorModel,
25056
- data: decodedData.data
25057
+ data: decodedData.data,
25058
+ resolution: getBmpResolution(decodedData)
25057
25059
  });
25058
25060
  }
25059
25061
  }
25062
+ /**
25063
+ * Gets image's resolution from its parsed data. BMP stores resolution in
25064
+ * pixels per meter.
25065
+ * @param bmp - Parsed BMP image.
25066
+ * @returns Object with resolution data if it is defined.
25067
+ */
25068
+ function getBmpResolution(bmp) {
25069
+ if (!bmp.xPixelsPerMeter || !bmp.yPixelsPerMeter) {
25070
+ return undefined;
25071
+ }
25072
+ return {
25073
+ x: bmp.xPixelsPerMeter,
25074
+ y: bmp.yPixelsPerMeter,
25075
+ unit: 'meter'
25076
+ };
25077
+ }
25060
25078
 
25061
25079
  const tagsById$2 = {
25062
25080
  0x829a: 'ExposureTime',