If you want to compare images in an automated test, take a look at the selenium-screenshot-watcher tool. I created this when I needed to determine if something changed in the UI, so that I was safe from a high-fidelity point of view. The tool is a REST-API client that is able to save images and provide feedback when asked to do a comparison. What it actually does is quite simple, based on some parameters that you build, so that you have a unique identifier for a screenshot that you’re about to take. Once that’s done, you will want to see if the tool has any history with those parameters, so that you would know if there is something that you would like to compare with.
Read more about it here.