{"id":15354769,"url":"https://github.com/bokuweb/image-diff-rs","last_synced_at":"2026-04-18T08:04:39.388Z","repository":{"id":209260610,"uuid":"446018693","full_name":"bokuweb/image-diff-rs","owner":"bokuweb","description":"This project provides an image differencing library that supports PNG,JPEG,GIF,TIFF,and WebP formats for Node.js, Deno, and Rust.","archived":false,"fork":false,"pushed_at":"2025-04-11T10:44:54.000Z","size":2741,"stargazers_count":16,"open_issues_count":6,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-15T06:16:54.704Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/bokuweb.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":"2022-01-09T07:08:53.000Z","updated_at":"2025-04-09T10:20:15.000Z","dependencies_parsed_at":"2023-11-26T08:27:45.531Z","dependency_job_id":"5c22c46b-4d52-41f2-a6cd-9e4a275d71a6","html_url":"https://github.com/bokuweb/image-diff-rs","commit_stats":{"total_commits":21,"total_committers":2,"mean_commits":10.5,"dds":"0.23809523809523814","last_synced_commit":"ffa78edad35317eafffc0acd3a7e9041015caa22"},"previous_names":["bokuweb/image-diff-rs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bokuweb%2Fimage-diff-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bokuweb%2Fimage-diff-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bokuweb%2Fimage-diff-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bokuweb%2Fimage-diff-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bokuweb","download_url":"https://codeload.github.com/bokuweb/image-diff-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249016644,"owners_count":21198833,"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":[],"created_at":"2024-10-01T12:20:53.450Z","updated_at":"2025-10-25T06:43:32.110Z","avatar_url":"https://github.com/bokuweb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# image-diff-rs\n\n\u003cimg src=\"https://github.com/bokuweb/image-diff-rs/workflows/Continuous%20Integration/badge.svg\" alt=\"Build Status\" /\u003e\n\nThis project provides an image differencing library that supports `PNG`,`JPEG`,`GIF`,`TIFF`,and `WebP` formats for `Node.js`, `Deno`, and `Rust`. For more details, please refer to each respective directory.\n\nThe code for `Node.js` and `Deno` is generated using `wit-bindgen` and `jco`.\n\n- JS: https://github.com/bokuweb/image-diff-rs/tree/main/js\n- Wasm: https://github.com/bokuweb/image-diff-rs/tree/main/wasm\n- Rust: https://github.com/bokuweb/image-diff-rs/tree/main/core\n\n## Demo\n\n| img1     | img2         | diff       |\n| --------------- |---------------| -------------------- |\n| ![](https://github.com/bokuweb/pixelmatch-rs/raw/main/fixtures/001a.png) | ![](https://github.com/bokuweb/pixelmatch-rs/raw/main/fixtures/001b.png) |![](https://github.com/bokuweb/pixelmatch-rs/raw/main/assets/diff1.png)|\n\n## JavaScript\n\n\n### installation\n\n```\nnpm install @bokuweb/image-diff-wasm\n```\n\n### examples\n\n```js\nimport { readFile } from \"node:fs/promises\";\nimport { diff } from \"@bokuweb/image-diff-wasm\";\n\nconst imga = await readFile(PATH_TO_IMAGE_A);\nconst imgb = await readFile(PATH_TO_IMAGE_B);\n\nconst result = diff(imga, imgb, { enableAntiAlias: true, threshold: 0.01 });\n```\n\n### API\n\n#### diff(imga: Uint8Array, imgb: Uint8Array, opts: Opts): Output;\n\nThe diff function is designed to compare two images and identify their differences.\nIt takes two image buffers as input and returns an `Output` object containing information about the differences.\n\n##### Input\n\n- `imga`: Uint8Array: The first image buffer.\n- `imgb`: Uint8Array: The second image buffer.\n- `opts`: Opts: Options object for the function.\n\n```Typescript\nexport interface Opts {\n  threshold?: number,\n  includeAntiAlias?: boolean,\n}\n```\n\n- `threshold`: Matching threshold, ranges from 0 to 1. Smaller values make the comparison more sensitive. 0.1 by default.\n- `includeAntiAlias`: The flag of antialias. If omitted false.\n\n##### Output\n\n```Typescript\nexport interface Output {\n  diffCount: number,\n  diffImage: Uint8Array,\n  width: number,\n  height: number,\n}\n```\n\n- `diffCount`: The number of pixels that differ between the two images.\n- `diffImage`: The buffer of the difference image in `WebP` format.\n- `width`: The width of the difference image.\n- `height`: The height of the difference image.\n\n##### Error\n\nThe function may throw following values as `ComponentError`.\n\n```Typescript\nexport type Error = ErrorDecode | ErrorEncode;\nexport interface ErrorDecode {\n  tag: 'decode',\n  val: string,\n}\nexport interface ErrorEncode {\n  tag: 'encode',\n  val: string,\n}\n```\n\n## Rust\n\n### Installation\n\n``` toml\nimage-diff-rs = { git = \"https://github.com/bokuweb/image-diff-rs.git\" }\n```\n\n### examples\n\n```Rust\npub fn main() {\n    let imga = std::fs::read(\"../fixtures/sample0.webp\").unwrap();\n    let imgb = std::fs::read(\"../fixtures/sample1.webp\").unwrap();\n\n    let _result = diff(\n        imga,\n        imgb,\n        \u0026DiffOption {\n            threshold: Some(0.01),\n            include_anti_alias: Some(true),\n        },\n    )\n    .unwrap();\n}\n```\n\n``` sh\ncargo run --example compare\n```\n\n## Wasm\n\n### Generate JS code from wasm component.\n\n```sh\nAR=llvm-ar CFLAGS='--sysroot ../wasi-sdk/share/wasi-sysroot' cargo wasi build --release\n```\n\n```sh\nwasm-tools component new target/wasm32-wasi/release/image_diff_wasm.wasm -o wasm/component.wasm --adapt wasm/wasi_snapshot_preview1.wasm\n```\n\n```sh\njco transpile wasm/component.wasm -o js --name index \u0026\u0026 mv js/index.js js/index.mjs\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbokuweb%2Fimage-diff-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbokuweb%2Fimage-diff-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbokuweb%2Fimage-diff-rs/lists"}