Compare images

activities

#1

Hi, how can I compare two images? In my scenario, I am selecting 1 image from a web page and another from my local and need to check if they are the same, OR check if that image exists in my local collection.


#2

Hi,

Load Image will give you an output variable of type “Image” which you can later use as input for the Find Image or Image exist activities, which should help you achieving what you would like to.



Cheers


#3

I used find image(to find the image from the web page, set a it to a variable- Image1) and load image(to load from the system). But I am unable to check if they are same. I used ‘Is Equal’ activity and set the type as UiPath.Core.UiElement, since that was the type acquired by the variable Image1.
When I use for each to to get all the files from the local to compare with that I got from the webpage, type mismatch occurs with the file and the image1.


#4

You would use the output of Image exist that you would assign to a Boolean variable and later you can check with a If, if it does exists.

Effectively, if you want to check each image stored as a file, that would be something like:

For each file (string) in Directory.GetFiles(path)
Load image (output to “img” var)
Image exists (Change the target selector to the element you want to check against,img as Image input, boolImageExists as output)
If boolImageExists then

  • Image exists logic
    Else
  • Image not exist logic
    End if
    Next

Cheers


Compare two images
#5

Hi @Florent_Salendres, can u plz provide the xaml file to compare two images which shows the differences also.