install prettier

This commit is contained in:
Victor Martinez 2024-04-04 10:11:08 +02:00
parent be431d38c6
commit 808a9e8140
5 changed files with 37 additions and 19 deletions

View file

@ -26,31 +26,31 @@ npm i imgphash
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
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
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
const image1 = await HashImage.fromUrl(url1);
const image2 = await HashImage.fromUrl(url2);
const hash1 = await image1.phash() // PHash instance
const hash2 = await image2.phash()
const similarity = hash1.compare(hash2)
const hash1 = await image1.phash(); // PHash instance
const hash2 = await image2.phash();
const similarity = hash1.compare(hash2);
```
> 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
const image1 = await HashImage.fromUrl(url1);
@ -65,8 +65,8 @@ const similarity = await image1.compare(image2);
👤 **Victor Martinez <jaster.victor@gmail.com>**
* Website: https://jasterv.com
* Github: [@JasterV](https://github.com/JasterV)
- Website: https://jasterv.com
- Github: [@JasterV](https://github.com/JasterV)
## 🤝 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 />
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)_

18
package-lock.json generated
View file

@ -16,7 +16,8 @@
"devDependencies": {
"@types/node": "^20.12.3",
"expect": "^29.7.0",
"mocha": "^10.4.0"
"mocha": "^10.4.0",
"prettier": "3.2.5"
}
},
"node_modules/@babel/code-frame": {
@ -1254,6 +1255,21 @@
"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": {
"version": "29.7.0",
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz",

View file

@ -24,7 +24,8 @@
"devDependencies": {
"@types/node": "^20.12.3",
"expect": "^29.7.0",
"mocha": "^10.4.0"
"mocha": "^10.4.0",
"prettier": "3.2.5"
},
"repository": {
"type": "git",

View file

@ -1,7 +1,7 @@
import { HashImage } from "../src/HashImage.js";
import { PHash } from "../src/PHash.js";
import {expect} from 'expect';
import { expect } from "expect";
const url1 =
"https://res.cloudinary.com/demo/image/upload/f_auto,q_auto/w_400/koala1.jpg";