{"id":13440621,"url":"https://github.com/reg-viz/img-diff-js","last_synced_at":"2025-12-24T16:34:06.441Z","repository":{"id":22782685,"uuid":"97305567","full_name":"reg-viz/img-diff-js","owner":"reg-viz","description":":art: Node.js library to compare 2 images without native libs.","archived":false,"fork":false,"pushed_at":"2024-09-17T07:36:44.000Z","size":1615,"stargazers_count":112,"open_issues_count":10,"forks_count":15,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-09-17T10:12:00.880Z","etag":null,"topics":["difference","image-processing"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/reg-viz.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":"2017-07-15T09:25:42.000Z","updated_at":"2024-09-17T07:36:47.000Z","dependencies_parsed_at":"2023-12-30T01:37:19.196Z","dependency_job_id":"86e7aa98-ab00-472b-915d-fcbcde2b1040","html_url":"https://github.com/reg-viz/img-diff-js","commit_stats":{"total_commits":163,"total_committers":8,"mean_commits":20.375,"dds":"0.39877300613496935","last_synced_commit":"521a1b0d8706f860dcc21716ec8bd05c7a7bc9a4"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reg-viz%2Fimg-diff-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reg-viz%2Fimg-diff-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reg-viz%2Fimg-diff-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reg-viz%2Fimg-diff-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reg-viz","download_url":"https://codeload.github.com/reg-viz/img-diff-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244595035,"owners_count":20478395,"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":["difference","image-processing"],"created_at":"2024-07-31T03:01:24.496Z","updated_at":"2025-12-24T16:34:06.410Z","avatar_url":"https://github.com/reg-viz.png","language":"TypeScript","readme":"# img-diff-js\n\n[![github actions](https://github.com/reg-viz/img-diff-js/workflows/build/badge.svg)](https://github.com/reg-viz/img-diff-js/actions)\n[![npm version](https://badge.fury.io/js/img-diff-js.svg)](https://badge.fury.io/js/img-diff-js)\n[![codecov](https://codecov.io/gh/reg-viz/img-diff-js/graph/badge.svg?token=6QopebRnI6)](https://codecov.io/gh/reg-viz/img-diff-js)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\n:art: Node.js library to compare 2 images without native libs.\n\n|            Actual             |             Expected              |        Difference         |\n| :---------------------------: | :-------------------------------: | :-----------------------: |\n| ![actual](example/actual.png) | ![expected](example/expected.png) | ![diff](example/diff.png) |\n\n## Install\n\n```sh\nnpm install img-diff-js\n```\n\n```js\nconst { imgDiff } = require(\"img-diff-js\");\n\nimgDiff({\n  actualFilename: \"example/actual.png\",\n  expectedFilename: \"example/expected.png\",\n  diffFilename: \"example/diff.png\",\n}).then(result =\u003e console.log(result));\n```\n\n## API Usage\n\n### `imgDiff(opt: ImgDiffOptions): Promise\u003cImgDiffResult\u003e`\n\nCreate image differential between two images.\n\n#### `ImgDiffOptions`\n\n```ts\n{\n  actualFilename: string;\n  expectedFilename: string;\n  diffFilename?: string;\n  generateOnlyDiffFile?: boolean; // default false\n  options?: {\n    threshold?: number;   // default 0.1\n    includeAA?: boolean;  // default false\n  }\n}\n```\n\n- `actualFilename` - _Required_ - Path to actual image file.\n- `expectedFilename` - _Required_ - Path to expected image file.\n- `diffFilename` - _Optional_ - Path to differential image file. If omitted, `imgDiff` does not output image file.\n- `generateOnlyDiffFile` - _Optional_ - Generate only files with difference\n- `options` - _Optional_ - An object to pass through [pixelmatch](https://github.com/mapbox/pixelmatch#api).\n\n#### `ImgDiffResult`\n\n```ts\n{\n  width: number;\n  height: number;\n  imagesAreSame: boolean;\n  diffCount: number;\n}\n```\n\n- `width` - Differential image's width.\n- `height` - Differential image's height.\n- `imagesAreSame` - It'll be true only if 2 images are same perfectly.\n- `diffCount` - The number of differential pixels.\n\n## Available format\n\nThe following codecs are available for input image files.\n\n- [x] png\n- [x] jpeg\n- [x] tiff (limited. See https://github.com/Quramy/decode-tiff#compatibility )\n- [ ] bmp\n\n`imgDiff` detects the input image format from it's extension name. For example, if the input file name ends with \".jpeg\", `imgDiff` attempts to decode in JPEG way regardless of the actual file format.\n\nThe output image format is PNG only.\n\n## Contribute\n\nPR or issue is welcome :)\n\n### Setup\n\n```sh\nyarn\n```\n\n### Test\n\n```sh\nyarn test\n```\n\n### Run benchmark script\n\n```sh\nyarn run perf\n```\n\n## License\n\nMIT License. See LICENSE under this repository.\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freg-viz%2Fimg-diff-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freg-viz%2Fimg-diff-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freg-viz%2Fimg-diff-js/lists"}