romankh3 / image-comparison

Published on Maven Central Java Library that compares 2 images with the same sizes and shows the differences visually by drawing rectangles. Some parts of the image can be excluded from the comparison. Can be used for automation QA tests.
https://t.me/romankh3
Apache License 2.0
337 stars 105 forks source link

Exception when maximalRectangleCount is bigger than rectangles.size() [BUG] #165

Closed Hexronimo closed 4 years ago

Hexronimo commented 4 years ago

When you set some wanted number of rectangles with imageComparison.setMaximalRectangleCount(10); (other then -1) and the comparing found fewer rectangles than this number, you got java.lang.IllegalArgumentException: -3 at ImageComparison.java:359 because in

       ` rectanglesForDraw = rectangles.stream()

                .sorted(Comparator.comparing(Rectangle::size))

                .skip(rectangles.size()-maximalRectangleCount)

                .collect(Collectors.toList());`

rectangles.size()-maximalRectangleCount will be negative number.

romankh3 commented 4 years ago

@Hexronimo, thanks for your catch. The bug will be published ASAP.

Best regards, Roman.

romankh3 commented 4 years ago

the new release has been published.