Skip to main content

Compare image files in different directories

Project description

ImDiff: Compare Directories of Images

ImDiff compares either two image files or two directory trees that contain image files with matching relative paths. It is intended for workflows where generated images need visual review as part of test development, golden-file updates, or artifact triage.

The project exposes the same comparison engine through two interfaces:

  • python -m imdiff LEFT RIGHT opens a Tk-based review window when the GUI stack is available, or warns and falls back to summary mode when it is not.
  • python -m imdiff --summary LEFT RIGHT prints a non-interactive summary and exits with a non-zero status when differences are found without importing any GUI-only modules.

When both arguments are directories, ImDiff walks the union of both directory trees, pairs files by relative path, and classifies each entry as:

  • identical: byte-identical files or text files with no unified diff output
  • similar: images whose normalized RMSE is below the project threshold
  • different: images or text files whose contents differ materially
  • different-size: image pairs with different dimensions
  • missing or new: a file exists on only one side
  • failed-to-load: a file exists but Pillow could not decode it as an image

The interactive directory view combines a file tree, image panes, and file operations so a reviewer can inspect left, right, and diff images, switch zoom policies, and copy or delete files directly from the comparison session.

This utility requires that the Tk Python packages be installed on the system. Hint for those running Ubuntu:

apt install python3-pil python3-pil.imagetk python3-tk

The application also depends on numpy and ttkbootstrap for image math and themed Tk widgets.

Usage

Compare two image files:

python -m imdiff path/to/expected.png path/to/actual.png

Compare two directories and print a CI-friendly summary:

python -m imdiff --summary tests/baseline-images tests/generated-images

When the GUI cannot be imported or Tk cannot start, the default interactive command warns on stderr and continues in the same summary mode used by --summary. This makes headless CI environments safe without changing the CLI command line.

Repository Layout

  • imdiff/image_comparator.py contains the lazy comparison model shared by the CLI and GUI.
  • imdiff/list_files.py pairs files across directory trees.
  • imdiff/cli/ contains the command-line entry points and summary printing.
  • imdiff/gui/ contains the Tk windows, canvases, menus, and directory browser.
  • developing/architecture.md describes the component relationships in more detail.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

imdiff-2.0.0.tar.gz (48.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

imdiff-2.0.0-py3-none-any.whl (48.9 kB view details)

Uploaded Python 3

File details

Details for the file imdiff-2.0.0.tar.gz.

File metadata

  • Download URL: imdiff-2.0.0.tar.gz
  • Upload date:
  • Size: 48.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for imdiff-2.0.0.tar.gz
Algorithm Hash digest
SHA256 10399fbf222db310666df696f7e7f6c60fce2ddd9607bc127412e6b64459d803
MD5 d79962bedf3050125142bb4389175d24
BLAKE2b-256 3e6dd0ef88ebb8d7c63ccbd1e8a9087ac6e26e3334ff8b245df112ff07eca38a

See more details on using hashes here.

File details

Details for the file imdiff-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: imdiff-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 48.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for imdiff-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9372b77b6bb2d08e27591a46fa7bd714b52c0b77ede9b38ed4e704ae3a678309
MD5 9b6abb407f97e87514c59b8935a55858
BLAKE2b-256 88a97212f3a9ac42b9f2a88236f50ad8b39503367cdc0e097a14ab530416c796

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page