
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
img-diff-js
Advanced tools
:art: Node.js library to compare 2 images without native libs.
Actual | Expected | Difference |
---|---|---|
![]() | ![]() | ![]() |
npm install img-diff-js
const { imgDiff } = require("img-diff-js");
imgDiff({
actualFilename: "example/actual.png",
expectedFilename: "example/expected.png",
diffFilename: "example/diff.png",
}).then(result => console.log(result));
imgDiff(opt: ImgDiffOptions): Promise<ImgDiffResult>
Create image differential between two images.
ImgDiffOptions
{
actualFilename: string;
expectedFilename: string;
diffFilename?: string;
generateOnlyDiffFile?: boolean; // default false
options?: {
threshold?: number; // default 0.1
includeAA?: boolean; // default false
}
}
actualFilename
- Required - Path to actual image file.expectedFilename
- Required - Path to expected image file.diffFilename
- Optional - Path to differential image file. If omitted, imgDiff
does not output image file.generateOnlyDiffFile
- Optional - Generate only files with differenceoptions
- Optional - An object to pass through pixelmatch.ImgDiffResult
{
width: number;
height: number;
imagesAreSame: boolean;
diffCount: number;
}
width
- Differential image's width.height
- Differential image's height.imagesAreSame
- It'll be true only if 2 images are same perfectly.diffCount
- The number of differential pixels.The following codecs are available for input image files.
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.
The output image format is PNG only.
PR or issue is welcome :)
yarn
yarn test
yarn run perf
MIT License. See LICENSE under this repository.
FAQs
Library to compare 2 images
The npm package img-diff-js receives a total of 102,922 weekly downloads. As such, img-diff-js popularity was classified as popular.
We found that img-diff-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.