{"id":13825933,"url":"https://github.com/whtsky/pixelmatch-py","last_synced_at":"2025-04-08T01:34:23.851Z","repository":{"id":38215936,"uuid":"218504363","full_name":"whtsky/pixelmatch-py","owner":"whtsky","description":"  A fast pixel-level image comparison library, originally created to compare screenshots in tests.","archived":false,"fork":false,"pushed_at":"2025-03-11T18:00:38.000Z","size":273,"stargazers_count":124,"open_issues_count":13,"forks_count":12,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-01T00:32:23.863Z","etag":null,"topics":["pixelmatch"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/pixelmatch/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/whtsky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-30T10:44:56.000Z","updated_at":"2025-03-28T20:39:51.000Z","dependencies_parsed_at":"2023-01-27T00:15:26.399Z","dependency_job_id":"94013da4-0da2-4270-8cf6-9110716a0b24","html_url":"https://github.com/whtsky/pixelmatch-py","commit_stats":{"total_commits":156,"total_committers":7,"mean_commits":"22.285714285714285","dds":0.25,"last_synced_commit":"1d912f90b8f46a1930bd7d719a81d5c8a6db0e9c"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whtsky%2Fpixelmatch-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whtsky%2Fpixelmatch-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whtsky%2Fpixelmatch-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whtsky%2Fpixelmatch-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whtsky","download_url":"https://codeload.github.com/whtsky/pixelmatch-py/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247760822,"owners_count":20991531,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pixelmatch"],"created_at":"2024-08-04T09:01:29.406Z","updated_at":"2025-04-08T01:34:23.823Z","avatar_url":"https://github.com/whtsky.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# pixelmatch-py\n\nA fast pixel-level image comparison library, originally created to compare screenshots in tests.\nNow with additional support of PIL.Image instances\nPython port of https://github.com/mapbox/pixelmatch.\n\nFeatures accurate **anti-aliased pixels detection**\nand **perceptual color difference metrics**.\n\n```python\nfrom pixelmatch import pixelmatch\n\nnum_diff_pixels = pixelmatch(img1, img2, 800, 600, diff, threshold=0.1)\n```\n\nImplements ideas from the following papers:\n\n- [Measuring perceived color difference using YIQ NTSC transmission color space in mobile applications](https://pdfs.semanticscholar.org/cb71/56034b6e427ddc9b5da1a4f5fcb10831c9fd.pdf) (2010, Yuriy Kotsarenko, Fernando Ramos)\n- [Anti-aliased pixel and intensity slope detector](https://www.researchgate.net/publication/234126755_Anti-aliased_Pixel_and_Intensity_Slope_Detector) (2009, Vytautas Vyšniauskas)\n\n## Install\n\n```bash\npython -m pip install pixelmatch\n```\n\n## Example usage\n\n### PIL.Image comparison\n\n```python\nfrom PIL import Image\n\nfrom pixelmatch.contrib.PIL import pixelmatch\n\nimg_a = Image.open(\"a.png\")\nimg_b = Image.open(\"b.png\")\nimg_diff = Image.new(\"RGBA\", img_a.size)\n\n# note how there is no need to specify dimensions\nmismatch = pixelmatch(img_a, img_b, img_diff, includeAA=True)\n\nimg_diff.save(\"diff.png\")\n```\n\n### Raw Image Data Comparison\n\n```python\nfrom pixelmatch import pixelmatch\n\nwidth, height = 1920, 1080\nimg_a = [R1, G1, B1, A1, R2, B2, G2, A2, ...]\nimg_b = [R1, G1, B1, A1, R2, B2, G2, A2, ...]\n\ndata_diff = [0] * len(img_a)\n\nmismatch = pixelmatch(img_a, img_b, width, height, data_diff, includeAA=True)\n```\n\n## API\n\n### pixelmatch(img1, img2, width, height, output, threshold, includeAA, alpha, aa_color, diff_color, diff_mask, fail_fast)\n\n- `img1`, `img2` — RGBA Image data of the images to compare. **Note:** image dimensions must be equal.\n- `width`, `height` — Width and height of the images.\n- `output` — Image data to write the diff to, or `None` if don't need a diff image. Note that _all three images_ need to have the same dimensions.\n- `threshold` — Matching threshold, ranges from `0` to `1`. Smaller values make the comparison more sensitive. `0.1` by default.\n- `includeAA` — If `true`, disables detecting and ignoring anti-aliased pixels. `false` by default.\n- `alpha` — Blending factor of unchanged pixels in the diff output. Ranges from `0` for pure white to `1` for original brightness. `0.1` by default.\n- `aa_color` — The color of anti-aliased pixels in the diff output in `[R, G, B]` format. `[255, 255, 0]` by default.\n- `diff_color` — The color of differing pixels in the diff output in `[R, G, B]` format. `[255, 0, 0]` by default.\n- `diff_mask` — Draw the diff over a transparent background (a mask), rather than over the original image. Will not draw anti-aliased pixels (if detected).\n- `fail_fast` - If true, will return after first different pixel.\n\nCompares two images, writes the output diff and returns the number of mismatched pixels.\n\n### contrib.PIL.pixelmatch\n\nCompares two images, writes the output diff and returns the number of mismatched pixels. Exact same API as `pixelmatch.pixelmatch` except for the important fact that it takes instances of PIL.Image for image parameters (`img1`, `img2`, and `output`) and the width/size need not be specified.\n\n## Example output\n\n| expected                                                                                                                                  | actual                                                                                                                                    | diff                                                                            |\n| ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |\n| ![https://github.com/whtsky/pixelmatch-py/raw/master/fixtures/4a.png](https://github.com/whtsky/pixelmatch-py/raw/master/fixtures/4a.png) | ![https://github.com/whtsky/pixelmatch-py/raw/master/fixtures/4b.png](https://github.com/whtsky/pixelmatch-py/raw/master/fixtures/4b.png) | ![1diff](https://github.com/whtsky/pixelmatch-py/raw/master/fixtures/4diff.png) |\n| ![https://github.com/whtsky/pixelmatch-py/raw/master/fixtures/3a.png](https://github.com/whtsky/pixelmatch-py/raw/master/fixtures/3a.png) | ![https://github.com/whtsky/pixelmatch-py/raw/master/fixtures/3b.png](https://github.com/whtsky/pixelmatch-py/raw/master/fixtures/3b.png) | ![1diff](https://github.com/whtsky/pixelmatch-py/raw/master/fixtures/3diff.png) |\n| ![https://github.com/whtsky/pixelmatch-py/raw/master/fixtures/6a.png](https://github.com/whtsky/pixelmatch-py/raw/master/fixtures/6a.png) | ![https://github.com/whtsky/pixelmatch-py/raw/master/fixtures/6b.png](https://github.com/whtsky/pixelmatch-py/raw/master/fixtures/6b.png) | ![1diff](https://github.com/whtsky/pixelmatch-py/raw/master/fixtures/6diff.png) |\n| ![https://github.com/whtsky/pixelmatch-py/raw/master/fixtures/7a.png](https://github.com/whtsky/pixelmatch-py/raw/master/fixtures/7a.png) | ![https://github.com/whtsky/pixelmatch-py/raw/master/fixtures/7b.png](https://github.com/whtsky/pixelmatch-py/raw/master/fixtures/7b.png) | ![1diff](https://github.com/whtsky/pixelmatch-py/raw/master/fixtures/7diff.png) |\n\n## Changelog\n\n### v0.3.0\n\n- feat: add fail_fast option [#144](https://github.com/whtsky/pixelmatch-py/pull/144)\n### v0.2.4\n- type: fix typing issues\n- chore: test Python 3.10\n\n### v0.2.3\n\n- feat: make package comply with PEP-561\n\n### v0.2.2\n\n- typing: use `Sequence` instead of `List` for `RGBTuple`\n- build: switch to `poetry_core` [#81](https://github.com/whtsky/pixelmatch-py/pull/81)\n\n### v0.2.1\n\n- feat: add function to compare PIL.Image instances through contrib.PIL.pixelmatch [#42](https://github.com/whtsky/pixelmatch-py/pull/42)\n\n### v0.2.0\n\n- BREAKING CHANGE: remove `options` parameter [#38](https://github.com/whtsky/pixelmatch-py/pull/38)\n- docs: use absolute url for images in README\n\n### v0.1.1\n\n- fix: fix bug in fast path [#18](https://github.com/whtsky/pixelmatch-py/pull/18)\n\n### v0.1.0\n\n- Initial release\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhtsky%2Fpixelmatch-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhtsky%2Fpixelmatch-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhtsky%2Fpixelmatch-py/lists"}