Skip to content

Commit 148979a

Browse files
committed
Merge branch 'master' of github.com:Prior99/native-image-diff
2 parents eb9d964 + 21a38fc commit 148979a

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,15 @@ const image2 = {
7070
};
7171

7272
const { image, pixels, totalDelta } = diffImages(image1, image2);
73-
// `image` now containes the width and the height of an RGBA image
73+
// `image` now contains the width and the height of an RGBA image
7474
// visualizing the difference between `image1` and `image2`.
75-
// `pixels` is the amount of pixels which didn't match.
76-
// `totalDelta` is a relatively scaled number with higher values being
77-
// the most different and `0` being total equal.
75+
// `pixels` is the number of pixels which didn't match.
76+
// `totalDelta` is a number denoting the relative difference
77+
// between the images with higher values being
78+
// the more different and `0` being entirely equal.
7879
```
7980

80-
The two buffers in `image1` and `image2` are expected to contain an RGB or RGBA encoded 8bit image. In the above example an RGB image was used.
81+
The two buffers in `image1` and `image2` are expected to contain an RGB or RGBA encoded 8-bit image. In the above example an RGB image was used.
8182

8283
Both images will be compared pixel-per-pixel and the result as well as a visualization of the difference is returned.
8384

@@ -124,23 +125,23 @@ A result might look like this:
124125

125126
#### pixels
126127

127-
This represents the total amount of pixels differing between both images.
128+
This represents the total number of pixels differing between both images.
128129

129130
#### totalDelta
130131

131132
This is the summed up total perceived difference of all pixels. It grows with the color difference of every unmatched pixel.
132133

133134
In comparison to the [pixels](https://prior99.github.io/native-image-diff/docs/interfaces/diffresult.html#pixels) property this property also represents how different all colors were. Comparing a white image
134-
with a black image would yield a higher difference as comparing an orange with a red image.
135+
with a black image would yield a higher difference than comparing an orange with a red image.
135136

136137
It doesn't feature any specific unit and should be used for relative comparisons only.
137138

138139
#### image
139140

140-
This property is only generate if [generateDiffImage](https://prior99.github.io/native-image-diff/docs/interfaces/diffimagesarguments.html#generatediffimage) is set to `true` (default).
141+
This property is only generated if [generateDiffImage](https://prior99.github.io/native-image-diff/docs/interfaces/diffimagesarguments.html#generatediffimage) is set to `true` (default).
141142

142-
It's properties `width` and `height` represent the dimensions of the generated image in pixels and `data` holds a RGBA buffer
143-
of raw image data showing the visual difference between both input images. Different pixels are drawn in red and pixels which
143+
Its properties `width` and `height` represent the dimensions of the generated image in pixels and `data` holds a RGBA buffer
144+
of raw image data showing the visual difference between both input images. Different pixels are drawn in red, and pixels which
144145
only differed between both images because of antialiasing will be drawn in yellow. This is only true if [detectAntialiasing](https://prior99.github.io/native-image-diff/docs/interfaces/diffimagesarguments.html#detectantialiasing)
145146
is set to `true` (default).
146147

@@ -222,11 +223,11 @@ The operations per second are displayed (Higher is better).
222223

223224
![diff benchmark](images/benchmark-diff.png)
224225

225-
*(The x-axis scale shows the amount of diffed images per second.)*
226+
*(The x-axis scale shows the number of diffed images per second.)*
226227

227228
## Contributing
228229

229-
Yarn is used instead of npm, so make sure it is installed, probably: `npm install -g yarn`.
230+
Yarn is used instead of npm, so make sure it is installed. `npm install -g yarn`.
230231

231232
Generally, it should be enough to just run:
232233

benchmark/src/with-antialiasing-detection.js renamed to benchmark/src/diff.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ module.exports = () => new Promise(resolve => {
99
const image1 = NodeLibpng.readPngFileSync(`${__dirname}/../../images/rainbow-1.png`);
1010
const image2 = NodeLibpng.readPngFileSync(`${__dirname}/../../images/rainbow-2.png`);
1111
const suite = new Benchmark.Suite();
12+
console.log(image1, image2)
13+
NativeImageDiff.diffImages(image1, image2);
1214
suite
1315
.add("native-image-diff", () => {
1416
NativeImageDiff.diffImages(image1, image2);

benchmark/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const benchmarkDiff = require("./with-antialiasing-detection");
1+
const benchmarkDiff = require("./diff");
22

33
benchmarkDiff()
44
.then(() => console.log("Done."));

benchmark/yarn.lock

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,13 +385,9 @@ nan@^2.4.0:
385385
resolved "https://registry.yarnpkg.com/nan/-/nan-2.10.0.tgz#96d0cd610ebd58d4b4de9cc0c6828cda99c7548f"
386386

387387
"native-image-diff@file:..":
388-
version "0.0.1"
388+
version "0.0.2"
389389
dependencies:
390-
node-fetch "^2.1.2"
391-
392-
node-fetch@^2.1.2:
393-
version "2.1.2"
394-
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.1.2.tgz#ab884e8e7e57e38a944753cec706f788d1768bb5"
390+
request "^2.85.0"
395391

396392
node-libpng@^0.2.0:
397393
version "0.2.0"

0 commit comments

Comments
 (0)