Skip to content

Commit 1db44ae

Browse files
committed
Update readme to reflect changes
1 parent c14477c commit 1db44ae

File tree

1 file changed

+23
-26
lines changed

1 file changed

+23
-26
lines changed

README.md

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,39 @@
22

33
Sharp based implementation of perceptual hash (phash) algorithm described [there](http://www.hackerfactor.com/blog/?/archives/432-Looks-Like-It.html).
44

5+
## Installation
6+
7+
```sh
8+
yarn add sharp sharp-phash
9+
# or
10+
npm i sharp sharp-phash
11+
```
12+
13+
You **must** install **sharp** yourself.
14+
515
## How to use
616

717
```js
8-
'use strict';
18+
"use strict";
919

10-
const fs = require('fs');
11-
const Promise = require('bluebird');
20+
const fs = require("fs");
21+
const Promise = require("bluebird");
1222

13-
const assert = require('assert');
23+
const assert = require("assert");
1424

15-
const phash = require('sharp-phash');
16-
const dist = require('sharp-phash/distance');
25+
const phash = require("sharp-phash");
26+
const dist = require("sharp-phash/distance");
1727

18-
const img1 = fs.readFileSync('./Lenna.png');
19-
const img2 = fs.readFileSync('./Lenna.jpg');
20-
const img3 = fs.readFileSync('./Lenna-sepia.jpg');
28+
const img1 = fs.readFileSync("./Lenna.png");
29+
const img2 = fs.readFileSync("./Lenna.jpg");
30+
const img3 = fs.readFileSync("./Lenna-sepia.jpg");
2131

22-
Promise.all([
23-
phash(img1),
24-
phash(img2),
25-
phash(img3)
26-
])
27-
.then(([hash1, hash2, hash3]) => {
32+
Promise.all([phash(img1), phash(img2), phash(img3)]).then(
33+
([hash1, hash2, hash3]) => {
2834
// hash returned is 64 characters length string with 0 and 1 only
2935
assert(dist(hash1, hash2) < 5);
3036
assert(dist(hash2, hash3) < 5);
3137
assert(dist(hash3, hash1) < 5);
32-
});
33-
```
34-
35-
## Your own sharp version
36-
37-
```js
38-
const sharp = require('sharp');
39-
const phash = require('sharp-phash');
40-
41-
phash(..., { sharp })
42-
38+
}
39+
);
4340
```

0 commit comments

Comments
 (0)