mirror of
https://codeberg.org/JasterV/imgphash.git
synced 2026-04-27 02:15:41 +00:00
install prettier
This commit is contained in:
parent
be431d38c6
commit
808a9e8140
5 changed files with 37 additions and 19 deletions
25
README.md
25
README.md
|
|
@ -26,31 +26,31 @@ npm i imgphash
|
||||||
|
|
||||||
This module provides a class `HashImage` that you can use to hash an image and compare it
|
This module provides a class `HashImage` that you can use to hash an image and compare it
|
||||||
|
|
||||||
+ Create a `HashImage` from a url
|
- Create a `HashImage` from a url
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const image = await HashImage.fromUrl(url1)
|
const image = await HashImage.fromUrl(url1);
|
||||||
```
|
```
|
||||||
|
|
||||||
+ Create a `HashImage` from a Node buffer
|
- Create a `HashImage` from a Node buffer
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const image = new HashImage(buffer)
|
const image = new HashImage(buffer);
|
||||||
```
|
```
|
||||||
|
|
||||||
+ Get the hash of 2 images and compare them
|
- Get the hash of 2 images and compare them
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const image1 = await HashImage.fromUrl(url1);
|
const image1 = await HashImage.fromUrl(url1);
|
||||||
const image2 = await HashImage.fromUrl(url2);
|
const image2 = await HashImage.fromUrl(url2);
|
||||||
const hash1 = await image1.phash() // PHash instance
|
const hash1 = await image1.phash(); // PHash instance
|
||||||
const hash2 = await image2.phash()
|
const hash2 = await image2.phash();
|
||||||
const similarity = hash1.compare(hash2)
|
const similarity = hash1.compare(hash2);
|
||||||
```
|
```
|
||||||
|
|
||||||
> The hash function returns an instance of `PHash`
|
> The hash function returns an instance of `PHash`
|
||||||
|
|
||||||
+ Or just compare 2 image objects, this is going to internally calculate their hash and use it
|
- Or just compare 2 image objects, this is going to internally calculate their hash and use it
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const image1 = await HashImage.fromUrl(url1);
|
const image1 = await HashImage.fromUrl(url1);
|
||||||
|
|
@ -65,8 +65,8 @@ const similarity = await image1.compare(image2);
|
||||||
|
|
||||||
👤 **Victor Martinez <jaster.victor@gmail.com>**
|
👤 **Victor Martinez <jaster.victor@gmail.com>**
|
||||||
|
|
||||||
* Website: https://jasterv.com
|
- Website: https://jasterv.com
|
||||||
* Github: [@JasterV](https://github.com/JasterV)
|
- Github: [@JasterV](https://github.com/JasterV)
|
||||||
|
|
||||||
## 🤝 Contributing
|
## 🤝 Contributing
|
||||||
|
|
||||||
|
|
@ -81,5 +81,6 @@ Give a ⭐️ if this project helped you!
|
||||||
Copyright © 2022 [Victor Martinez <jaster.victor@gmail.com>](https://github.com/JasterV).<br />
|
Copyright © 2022 [Victor Martinez <jaster.victor@gmail.com>](https://github.com/JasterV).<br />
|
||||||
This project is [MIT](https://github.com/JasterV/imgphash/blob/main/LICENSE) licensed.
|
This project is [MIT](https://github.com/JasterV/imgphash/blob/main/LICENSE) licensed.
|
||||||
|
|
||||||
***
|
---
|
||||||
|
|
||||||
_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_
|
_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_
|
||||||
18
package-lock.json
generated
18
package-lock.json
generated
|
|
@ -16,7 +16,8 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^20.12.3",
|
"@types/node": "^20.12.3",
|
||||||
"expect": "^29.7.0",
|
"expect": "^29.7.0",
|
||||||
"mocha": "^10.4.0"
|
"mocha": "^10.4.0",
|
||||||
|
"prettier": "3.2.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@babel/code-frame": {
|
"node_modules/@babel/code-frame": {
|
||||||
|
|
@ -1254,6 +1255,21 @@
|
||||||
"url": "https://github.com/sponsors/jonschlinkert"
|
"url": "https://github.com/sponsors/jonschlinkert"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/prettier": {
|
||||||
|
"version": "3.2.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz",
|
||||||
|
"integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==",
|
||||||
|
"dev": true,
|
||||||
|
"bin": {
|
||||||
|
"prettier": "bin/prettier.cjs"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/pretty-format": {
|
"node_modules/pretty-format": {
|
||||||
"version": "29.7.0",
|
"version": "29.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz",
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,8 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^20.12.3",
|
"@types/node": "^20.12.3",
|
||||||
"expect": "^29.7.0",
|
"expect": "^29.7.0",
|
||||||
"mocha": "^10.4.0"
|
"mocha": "^10.4.0",
|
||||||
|
"prettier": "3.2.5"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { HashImage } from "../src/HashImage.js";
|
import { HashImage } from "../src/HashImage.js";
|
||||||
import { PHash } from "../src/PHash.js";
|
import { PHash } from "../src/PHash.js";
|
||||||
|
|
||||||
import {expect} from 'expect';
|
import { expect } from "expect";
|
||||||
|
|
||||||
const url1 =
|
const url1 =
|
||||||
"https://res.cloudinary.com/demo/image/upload/f_auto,q_auto/w_400/koala1.jpg";
|
"https://res.cloudinary.com/demo/image/upload/f_auto,q_auto/w_400/koala1.jpg";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue