looks-same icon indicating copy to clipboard operation
looks-same copied to clipboard

Add equal feedback in createDiff.

Open RamzesTheSecond opened this issue 6 years ago • 7 comments

It would be great to know if the images are equal or not when creating diff.

looksSame.createDiff({ ... }, function (error, equal) { ... });

RamzesTheSecond avatar Dec 15 '18 09:12 RamzesTheSecond

Hello.

Can you please describe a use case of this feature? It is assumed that you need compare images at first and than if they have difference call createDiff method.

Example:

looksSame('ref.png', 'curr.png', (err, equal) => {
  if (!equal) {
    looksSame.createDiff({...}, () => {...})
  }
})

DudaGod avatar Dec 15 '18 10:12 DudaGod

Yes sure. I need to create a diff image regardless if it has differences or not. I use it for e2e tests and there are scenarios with steps where each step should be visible and additionally I want to show which steps have some difference.

RamzesTheSecond avatar Dec 15 '18 20:12 RamzesTheSecond

Okay, you can do it like I described above:

looksSame('ref.png', 'curr.png', (err, equal) => {
    looksSame.createDiff({...}, () => {...});

    console.log(`Images are equal: ${equal}`);
})

Is it suitable for you?

DudaGod avatar Dec 17 '18 06:12 DudaGod

Thanks for the answer. Unfortunately it's not the option I need - it simply takes more time to compare images and generate diff. In this case it will take longer than expected. I have loads of scenarios and images to compare.

RamzesTheSecond avatar Dec 17 '18 12:12 RamzesTheSecond

Ok, I understand you. We are currently busy with other tasks so the PR is welcome. By the way, this is not difficult to do.

DudaGod avatar Dec 17 '18 18:12 DudaGod

@DudaGod Hello. I have created a Pull Request regarding this issue, could you please take a look at it? https://github.com/gemini-testing/looks-same/pull/94

kspace-trk avatar Sep 14 '23 04:09 kspace-trk

@DudaGod Hello. I have created a Pull Request regarding this issue, could you please take a look at it?

Hello. Did you try to use lookSame with option createDiffImage: true? In this case the execution speed should be the same as when calling createDiff.

You can use it like:

const {equal} = await looksSame('image1.png', 'image2.png', {createDiffImage: true});

DudaGod avatar Sep 14 '23 09:09 DudaGod