https://github.com/simonw/image-diff
CLI tool for comparing images
https://github.com/simonw/image-diff
Last synced: 12 days ago
JSON representation
CLI tool for comparing images
- Host: GitHub
- URL: https://github.com/simonw/image-diff
- Owner: simonw
- License: apache-2.0
- Created: 2022-03-11T21:59:27.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-09-19T19:42:35.000Z (almost 3 years ago)
- Last Synced: 2025-06-02T16:22:42.359Z (about 1 month ago)
- Language: Python
- Homepage:
- Size: 18.6 KB
- Stars: 35
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# image-diff
[](https://pypi.org/project/image-diff/)
[](https://github.com/simonw/image-diff/releases)
[](https://github.com/simonw/image-diff/actions?query=workflow%3ATest)
[](https://github.com/simonw/image-diff/blob/master/LICENSE)CLI tool for comparing images
## Installation
Install this tool using `pip`:
$ pip install image-diff
## Image diff
To generate an image showing the difference between two images:
image-diff first.jpg second.jpg -o diff.png
## Count differing pixels
To count the number of pixels that have changed, use `image-diff count`:
image-diff first.jpg second.jpg
This will output a number followed by a newline.
## Compile an image
The `image-diff compile` command exists mainly to make this tool easier to test.
It can be used to compile an image from a JSON definition - for example:
echo '[
[[0, 0, 0], [0, 0, 0], [0, 0, 0]],
[[0, 0, 0], [255, 0, 0], [0, 0, 0]],
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
]' | image-diff compile - -o one-pixel.png## Similar projects
- [pixelmatch](https://github.com/mapbox/pixelmatch) by Mapbox is a JavaScript library with an accompanying CLI tool.
## Development
To contribute to this tool, first checkout the code. Then create a new virtual environment:
cd image-diff
python -m venv venv
source venv/bin/activateOr if you are using `pipenv`:
pipenv shell
Now install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
pytest