How to use the resemblejs/compareImages function in resemblejs

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 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',
  })
}

resemblejs

Image analysis and comparison with HTML5

MIT
Latest version published 11 months ago

Package Health Score

69 / 100
Full package analysis