Package: pybind11-pixelmatch
about python packageinstallpip install pybind11-pixelmatchdiff imagepip install fire # for CLI
python3 -m pybind11_pixelmatch --help
python3 -m pybind11_pixelmatch data/pic1.png data/pic2.png diff_output.pnglabelimageimg1img2diff# diffColor -> delete
# diffColorAlt -> insert
python3 -m pybind11_pixelmatch data/pic1.png data/pic2.png --output data/diff.png --diffColor='#ff0000' --diffColorAlt='#00ff00'labelimageimg1img2diffIf you want a pure python package, then trypip install pixelmatch.
But it'smuch slower.pixelmatch-cpp17A C++17 port of the JavaScript pixelmatch library, providing a small pixel-level image comparison library.Features accurateanti-aliased pixels detectionandperceptual color difference metrics.Based onmapbox/pixelmatch.  pixelmatch-cpp17 is around300 lines of code, and hasno dependencies, operating on RGBA-encoded buffers.pixelmatch::Optionsoptions;options.threshold=0.1f;conststd::vector<uint8_t>img1=...;conststd::vector<uint8_t>img2=...;std::vector<uint8_t>diffImage(img1.size());constintnumDiffPixels=pixelmatch::pixelmatch(img1,img2,diffImage,width,height,stride,options);Compared tomapbox/pixelmatch-cpp, pixelmatch-cpp17 ports the latest features from the JavaScript library, and is built with production-grade practices, including thorough test coverage and fuzz-testing.  Build files are included for Bazel, but contributions for other build systems are welcome.Implements ideas from the following papers:Measuring perceived color difference using YIQ NTSC transmission color space in mobile applications(2010, Yuriy Kotsarenko, Fernando Ramos)Anti-aliased pixel and intensity slope detector(2009, Vytautas Vyšniauskas)Example outputexpectedactualdiffAPIpixelmatch(img1, img2, output, width, height, strideInPixels[, options])img1,img2— Image data of the images to compare, as a RGBA-encoded byte array.Note:image dimensions must be equal.output— Image data to write the diff to, orstd::nulloptif you don't need a diff image.width,height— Width and height of the images. Note thatall three imagesneed to have the same dimensions.strideInPixels— Stride of the images. Note thatall three imagesneed to have the same stride.optionsis a struct with the following fields:threshold— Matching threshold, ranges from0.0fto1.0f. Smaller values make the comparison more sensitive.0.1by default.includeAA— Iftrue, disables detecting and ignoring anti-aliased pixels.falseby default.alpha— Blending factor of unchanged pixels in the diff output. Ranges from0for pure white to1for original brightness.0.1by default.aaColor— The color of anti-aliased pixels in the diff output as an RGBA color.(255, 255, 0, 255)by default.diffColor— The color of differing pixels in the diff output as an RGBA color(255, 0, 0, 255)by default.diffColorAlt— An alternative color to use for dark on light differences to differentiate between "added" and "removed" parts. If not provided, all differing pixels use the color specified bydiffColor.std::nulloptby default.diffMask— Draw the diff over a transparent background (a mask), rather than over the original image. Will not draw anti-aliased pixels (if detected).Compares two images, writes the output diff and returns the number of mismatched pixels.UsageBazelAdd the following to yourWORKSPACEfile:git_repository(name="pixelmatch-cpp17",branch="main",remote="https://github.com/jwmcglynn/pixelmatch-cpp17",)Then add a dependency on@pixelmatch-cpp17:cc_test(name="my_test",# ...data=glob(["testdata/*.png",]),deps=["@pixelmatch-cpp17",# ...],)In your test file, include pixelmatch with:#include<pixelmatch/pixelmatch.h>