Skip to content

Commit f34fe70

Browse files
committed
Add public api for comparing images with diff
1 parent c0f6617 commit f34fe70

File tree

1 file changed

+21
-0
lines changed
  • src/main/java/com/assertthat/selenium_shutterbug/core

1 file changed

+21
-0
lines changed

src/main/java/com/assertthat/selenium_shutterbug/core/Snapshot.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,27 @@ public boolean equals(BufferedImage image, double deviation) {
193193
return getImage() != null ? ImageProcessor.imagesAreEquals(getImage(), image, deviation) : image == null;
194194
}
195195

196+
/**
197+
* @param image BufferedImage to compare with.
198+
* @param resultingImagePath path to save to resulting images with diff
199+
* @return true if the the provided image and current image are strictly equal.
200+
*/
201+
public boolean equalsWithDiff(BufferedImage image, String resultingImagePath) {
202+
if (this.getImage() == image) return true;
203+
return getImage() != null ? ImageProcessor.imagesAreEqualsWithDiff(getImage(), image,resultingImagePath, 0) : image == null;
204+
}
205+
206+
/**
207+
* @param image BufferedImage to compare with.
208+
* @param resultingImagePath path to save to resulting images with diff
209+
* @param deviation allowed deviation while comparing
210+
* @return true if the the provided image and current image are strictly equal.
211+
*/
212+
public boolean equalsWithDiff(BufferedImage image, String resultingImagePath, double deviation) {
213+
if (this.getImage() == image) return true;
214+
return getImage() != null ? ImageProcessor.imagesAreEqualsWithDiff(getImage(), image,resultingImagePath, deviation) : image == null;
215+
}
216+
196217
/**
197218
* @return image hash code
198219
*/

0 commit comments

Comments
 (0)