18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
How to compare 2 images and generate the report?
Hi,
I wanted to compare two images through Sahi. Can you pls help me out.
Thanks,
Krishna
I wanted to compare two images through Sahi. Can you pls help me out.
Thanks,
Krishna
Best Answer
-
Hi divkrishna
my suggestion would be to download the images through sahi and then _execute a script to compare these images. I can recommend http://www.imagemagick.org/Usage/compare/
Then _readFile the result and _assert if there is a difference.
Regards
Wormi

Answers
I have another question that once i compare images then it will be in form of image(compare.jpg) , so how will i use _readfile to read the image?
Awaiting for your reply.
Thanks,
Krishna
Check for red:
Write the output from from imagemagick into a file _readFile the file and check the channal statistics if reds mean is like above 50%
and/or
Write the result from into a file. If then there is no difference in the picures.
@see all from http://www.imagemagick.org/script/compare.php
Add imagemagick to Sahi: http://im4java.sourceforge.net/api/
Or maybe you could just let an _execute() fail. Like when execution of compare not returns "inf" fail with exit status and wrap this _execute in a try-catch-block.
I have never tried to compare two images through Sahi.I want to know that if there is any image tool which supports to do that directly.I have tried another image tool:
http://www.rasteredge.com/how-to/csharp-imaging/
But it said that they can not work with Sahi.Thanks for any suggestions.