How to use resemblejs - 5 common examples

To help you get started, we’ve selected a few resemblejs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github material-components / material-components-web-react / test / screenshot / screenshot.tsx View on Github external
test(this.urlPath_, async () => {
      // Get the golden file path from the golden hash
      const goldenHash = await this.getGoldenHash_();
      const goldenPath = this.getImagePath_(goldenHash, 'golden');
      if (!goldenPath) {
        console.error('no goldenPath found');
        return;
      }
      // Take a snapshot and download the golden image
      const [snapshot, golden] = await Promise.all([
        this.takeScreenshot_(),
        this.readImage_(goldenPath),
      ]);
      // Compare the images
      const data = await compareImages(snapshot, golden, comparisonOptions);
      const diff = data.getBuffer();
      // Use the same hash for the snapshot path and diff path so it's easy can associate the two
      const snapshotHash = this.generateImageHash_(snapshot);
      const snapshotPath = this.getImagePath_(snapshotHash, 'snapshot');
      const diffPath = this.getImagePath_(snapshotHash, 'diff');
      const metadata: Storage.CustomFileMetadata = {golden: goldenHash};
      if (!snapshotPath) {
        console.error('no snapshotPath found');
        return;
      }
      if (!diffPath) {
        console.error('no diffPath found');
        return;
      }
      // Save the snapshot and the diff
      if (storage) {
github Kitware / vtk-js / Sources / Testing / testUtils.js View on Github external
baselines.forEach((baseline, idx) => {
    resemble(baseline)
      .compareTo(image)
      .ignoreAntialiasing()
      .onComplete((data) => {
        if (minDelta >= data.misMatchPercentage) {
          minDelta = data.misMatchPercentage;
          minDiff = data.getImageDataUrl();
        }
        isSameDimensions = isSameDimensions || data.isSameDimensions;

        if (idx + 1 === nbBaselines) {
          done();
        }
      });
  });
}
github Kitware / vtk-js / Sources / Testing / testUtils.js View on Github external
if (minDelta >= threshold) {
      tapeContext.fail(
        `<img src="${image}"> vs <img src="${
          baselines[0]
        }"> === <img src="${minDiff}">`
      );
    }

    if (nextCallback) {
      nextCallback();
    } else {
      tapeContext.end();
    }
  }

  resemble.outputSettings({
    transparency: 0.5,
  });
  baselines.forEach((baseline, idx) =&gt; {
    resemble(baseline)
      .compareTo(image)
      .ignoreAntialiasing()
      .onComplete((data) =&gt; {
        if (minDelta &gt;= data.misMatchPercentage) {
          minDelta = data.misMatchPercentage;
          minDiff = data.getImageDataUrl();
        }
        isSameDimensions = isSameDimensions || data.isSameDimensions;

        if (idx + 1 === nbBaselines) {
          done();
        }
github gymnastjs / picturebook / src / utils / image.js View on Github external
left: number,
    right: number,
    bottom: number,
  },
  dimensionDifference: {
    height: number,
    width: number,
  },
  isSameDimensions: boolean,
  misMatchPercentage: string,
  error: void | string,
|}> {
  const img1 = readFileSync(imgPath1)
  const img2 = readFileSync(imgPath2)

  return compareImages(img1, img2, {
    output: {
      errorColor: {
        red: 255,
        green: 0,
        blue: 255,
      },
      errorType: 'movement',
      transparency: 0.3,
      largeImageThreshold: 1200,
      useCrossOrigin: false,
      outputDiff: true,
    },
    scaleToSameSize: true,
    ignore: 'antialiasing',
  })
}
github ddo / node-resemble / index.js View on Github external
module.exports = function() {
    if (typeof window === "undefined") {
        global.window = overrideWindow()
    }
    if (typeof FileReader === "undefined") {
        global.FileReader = overrideFileReader()
    }
    if (typeof Image === "undefined") {
        global.Image = overrideImage()
    }
    const resemblejs = require('resemblejs');
    return resemblejs.apply(this, arguments);
};

resemblejs

Image analysis and comparison with HTML5

MIT
Latest version published 11 months ago

Package Health Score

69 / 100
Full package analysis