friendly-img-hash-js 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# friendly-
|
|
1
|
+
# friendly-img-hash-js
|
|
2
2
|
|
|
3
3
|
A js implementation of https://docs.rs/img_hash/ which itself is based on the work of http://www.hackerfactor.com/.
|
|
4
4
|
|
|
@@ -18,7 +18,7 @@ Browser example:
|
|
|
18
18
|
import { hash } from 'friendly-img-hash-js';
|
|
19
19
|
|
|
20
20
|
// Construct a hash!
|
|
21
|
-
const result = hash('https://my-sweet-image-url.png');
|
|
21
|
+
const result = await hash('https://my-sweet-image-url.png');
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
Nodejs Example:
|
|
@@ -27,7 +27,7 @@ Nodejs Example:
|
|
|
27
27
|
import { hash } from 'friendly-img-hash-js';
|
|
28
28
|
|
|
29
29
|
// Construct a hash!
|
|
30
|
-
const result = hash('./some/file/on/disk.png');
|
|
30
|
+
const result = await hash('./some/file/on/disk.png');
|
|
31
31
|
|
|
32
32
|
```
|
|
33
33
|
|
|
@@ -48,7 +48,7 @@ import { hash, Convert } from 'friendly-img-hash-js';
|
|
|
48
48
|
|
|
49
49
|
// Example of how to specify that option
|
|
50
50
|
console.log(
|
|
51
|
-
hash(image {
|
|
51
|
+
await hash(image {
|
|
52
52
|
output: Convert.options.BigInt
|
|
53
53
|
})
|
|
54
54
|
);
|
|
@@ -71,7 +71,7 @@ import { hash, Hash } from 'friendly-img-hash-js';
|
|
|
71
71
|
|
|
72
72
|
// Example of how to specify that option
|
|
73
73
|
console.log(
|
|
74
|
-
hash(image, {
|
|
74
|
+
await hash(image, {
|
|
75
75
|
algorithm: Hash.options.Gradient
|
|
76
76
|
})
|
|
77
77
|
);
|
|
@@ -91,7 +91,7 @@ const imageBytes = // get your image bytes following the examples above.
|
|
|
91
91
|
|
|
92
92
|
// Example of how to specify that option
|
|
93
93
|
console.log(
|
|
94
|
-
hash(image, {
|
|
94
|
+
await hash(image, {
|
|
95
95
|
dct: {
|
|
96
96
|
algorithm: Dct.options.Type2
|
|
97
97
|
}
|
|
@@ -106,7 +106,7 @@ If you want to write your own algorithm, you can for any option. Here is an exam
|
|
|
106
106
|
import { hash } from 'friendly-img-hash-js';
|
|
107
107
|
|
|
108
108
|
console.log(
|
|
109
|
-
hash(image, {
|
|
109
|
+
await hash(image, {
|
|
110
110
|
// Dimension is required because of custom algorithm
|
|
111
111
|
dimension: (width, height) => ({ width, height }),
|
|
112
112
|
algorithm: (bytes) => {
|
|
@@ -129,10 +129,10 @@ import leven from 'leven';
|
|
|
129
129
|
|
|
130
130
|
const config = { output: Convert.options.BigInt };
|
|
131
131
|
|
|
132
|
-
const result1 = hash(image1, config);
|
|
133
|
-
const result2 = hash(image2, config);
|
|
132
|
+
const result1 = await hash(image1, config);
|
|
133
|
+
const result2 = await hash(image2, config);
|
|
134
134
|
|
|
135
|
-
if (leven(result1, result2) <= 12) {
|
|
135
|
+
if (leven(result1.toString(), result2.toString()) <= 12) {
|
|
136
136
|
console.log ('Images are very similar!');
|
|
137
137
|
}
|
|
138
138
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "friendly-img-hash-js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "User friendly algorithms for generating image hashes.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"mocha": "^10.2.0"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"img-hash-js-core": "^1.0.
|
|
40
|
+
"img-hash-js-core": "^1.0.7",
|
|
41
41
|
"jimp": "^0.22.10"
|
|
42
42
|
}
|
|
43
43
|
}
|