« back to all links

Image Comparison Library (Python)

2023-11-14

You can find the repository for this project here.

Overview

This Python library provides a set of tools for image comparison, especially useful for screenshot comparison testing in environments with limited testing hooks. It's built on top of the Pillow library, with additional use of numpy and opencv-python (cv2) for more advanced image processing.

Key Features

  1. Initialization: The ComparisonImageLibrary class can be initialized with either a file path or an image object. This flexibility allows direct loading from files or manipulation of already loaded images.

  2. Image Properties and Conversion:

  1. Image Manipulation:
  1. Image Comparison:
  1. Image Saving: The save method allows for writing the image to a file, supporting different formats.

Usage Scenarios

This library is particularly useful for automated screenshot testing in environments where direct hooks into the product are unavailable. By comparing screenshots against expected images, it can validate UI changes or detect anomalies.

Testing

The library includes inline doctest examples, demonstrating usage and validating functionality.

Design Considerations