Forum Discussion

TestQA1's avatar
TestQA1
Frequent Contributor
10 months ago
Solved

Locking image size to certain value for image comparison

Hi,

 

I use 'Difference' method to compare image versions. 

For example: Images saved on a particular past date are compared with images saved on a current date.

I am using certain parameters such as Pixel tolerance with 'Difference' method to prevent image failure due to certain number of pixel difference.

But the size of old and new images have always been an issue. If we change machine, the size changes significantly and the comparison affects.

Is there any way we can give images certain size so every time we need comparison the size is not an issue.

 

Thank you. 

  • Good morning!

    Image size variations can indeed affect the accuracy of your comparisons, especially when you switch machines with different settings. However, there's a solution that can help you achieve more consistent results: image resizing.

     

    Before performing the comparison, it's recommended to resize both the old and new images to a standard size. By doing this, you eliminate the discrepancies caused by varying image dimensions. In TestComplete, you have the option to utilize its built-in image manipulation capabilities for resizing. Alternatively, if you're comfortable with Python scripting, you can leverage external libraries like OpenCV to achieve this.

     

    When resizing the images, it's crucial to maintain the original aspect ratio to prevent any distortions in the visuals. Keeping the aspect ratio intact ensures that the images retain their proper proportions during the resizing process.

     

    any questions? please don't hesitate to ask.

2 Replies

  • KB1's avatar
    KB1
    Champion Level 2

    Good morning!

    Image size variations can indeed affect the accuracy of your comparisons, especially when you switch machines with different settings. However, there's a solution that can help you achieve more consistent results: image resizing.

     

    Before performing the comparison, it's recommended to resize both the old and new images to a standard size. By doing this, you eliminate the discrepancies caused by varying image dimensions. In TestComplete, you have the option to utilize its built-in image manipulation capabilities for resizing. Alternatively, if you're comfortable with Python scripting, you can leverage external libraries like OpenCV to achieve this.

     

    When resizing the images, it's crucial to maintain the original aspect ratio to prevent any distortions in the visuals. Keeping the aspect ratio intact ensures that the images retain their proper proportions during the resizing process.

     

    any questions? please don't hesitate to ask.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Changing the scale of an image, may visually look the same, but when comparing, it will be different.

     

    When it comes to image comparison, you need to ensure your environments are exactly the same.