rsmbl / Resemble.js

Image analysis and comparison

Home Page:http://rsmbl.github.io/Resemble.js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Random compare output image

mspace opened this issue · comments

I'm using angular 15 and resemblejs v4.1.0. When compare dialog is opened for multiple times, randomly the compare output swaps left file with right and compare right file with left and not vice-versa.

So the sometimes we get this:

image

and other times (happens randomly) this:

image

Code:

 // left and right images loaded
    if (this.leftFile?.image && this.rightFile?.image && this.leftFile?.includeInCompare && this.rightFile?.includeInCompare) {
      resemble.outputSettings({ useCrossOrigin: false, errorType: 'movement' });

      const leftImageType: string = imageTypeFromExtension(this.leftFile.extension);
      const rightImageType: string = imageTypeFromExtension(this.rightFile.extension);

      const diff: resemble.Comparison = resemble(`data:image/${leftImageType};base64,${this.leftFile.image}`)
        .compareTo(`data:image/${rightImageType};base64,${this.rightFile.image}`)
        .onComplete((data: resemble.ComparisonResult): void => {
          this.compareImage = data.getImageDataUrl();
        });

      return;
    }

I noticed that if we comment next line, compare works fine all the time

resemble.outputSettings({ useCrossOrigin: false, errorType: 'movement' });

Any ideas?