18 January 2026:


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?

divkrishnadivkrishna Members
edited January 2014 in Sahi Pro
Hi,

I wanted to compare two images through Sahi. Can you pls help me out.

Thanks,
Krishna

Best Answer

Answers

  • divkrishnadivkrishna Members
    edited January 2014
    Thanks,

    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
  • globalwormingglobalworming Moderators
    edited February 2014
    Your compare.jpeg colors red all differences in the 2 compared images. So you need o check for the amount (or existance) of red in the images.
    Check for red:
    Write the output from from imagemagick into a file
    identify -verbose compare.jpg
    
    _readFile the file and check the channal statistics if reds mean is like above 50%

    and/or

    Write the result from
    compare -channel red -metric PSNR assertImage.png existsImage.png  compare.png 
    
    into a file. If
    _readFile() == "inf"
    
    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.
  • HI there
    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.
  • There is no "direct through Sahi" as far as I know. But as I said you can include Imagemagick in Sahi to provide image comparison via Sahi Api.
  • Thanks for your nice sharing.I'll have a try
Sign In or Register to comment.