Compare images between them in Java?

416 views
Skip to first unread message

pboix

unread,
Dec 1, 2015, 9:35:39 AM12/1/15
to Galen Framework
I am trying to setup a project which can take a full screenshot of a webpage, and then compare it to see if there are any differences (basically, implementing a visual testing tool). I am trying to compare an image with another one by simply creating a dumpPage, and then trying to compare it. Is there a trivial way to solve that without having any specs file defined or whatsoever?

Ivan Shubin

unread,
Dec 7, 2015, 5:21:59 AM12/7/15
to Galen Framework
Hi, 

I am actually right now working on something similar in here https://github.com/galenframework/galen-sample-tests/blob/master/tests/init.js#L195
It already works but I would like to refactor that function a bit so that it is more flexible. Also I will have to write docs for it. It should be ready this week.

It works like this:
1) You give it a spec file that you already have. 
2) It parses the spec file and throws away everything except page objects.
3) Then it looks into specified storage if there are any sample images
4) The first time there are of course no images, so it will throw an error
5) Then it makes a page dump and copies all the images into that storage in <iteration + 1> folder
6) Next time you run this test it will pick up the images from the storage and will compare it with sample images from previous run

I am not sure what you are looking for, but if you don't like this idea you can also just look at Rainbow4J from galen-rainbow4j library and use it for your own solution

Kind regards,
Ivan

pau....@gmail.com

unread,
Dec 16, 2015, 10:09:13 AM12/16/15
to Galen Framework
I read your JS test and I finally re-implemented my own solution using Rainbow4J. This is exactly what I needed.

Thanks a lot for the tips. Great tool!

Cheers!

Ivan Shubin

unread,
Dec 16, 2015, 10:16:25 AM12/16/15
to Galen Framework
Cool! by the way I have implemented the stuff that I was talking about in previous message. You can find it here https://github.com/galenframework/galen-bootstrap/blob/master/imageDiff-example.test.js
Though there is no documentation yet

Purusothaman Ramanujam

unread,
Mar 7, 2016, 3:35:35 AM3/7/16
to Galen Framework
Hi Ivan,

I could not find that feature you have mentioned for image diff. Can you please let me know if it's in any new location?

I am trying to do layout testing without creating any spec file. Just image based comparison on different browsers.

Ivan Shubin

unread,
Mar 13, 2016, 5:05:01 PM3/13/16
to Galen Framework
I don't understand what you want. In Galen you have to use a spec file as you have to somehow declare all the elements on the page. If you don't care about that and just want to compare complete screenshot only, then you could just generate a spec file dynamically and insert something like:

= Image validation =
    screen
:
        image file imgs
/sample-01.png

Devendra Shrivastava

unread,
Aug 30, 2020, 4:45:24 AM8/30/20
to Galen Framework
Hi Ivan, I tried above but it gives NullPointerException.

Devendra Shrivastava

unread,
Aug 30, 2020, 6:08:58 AM8/30/20
to Galen Framework

I downloaded the latest galen now it is working.
Reply all
Reply to author
Forward
0 new messages