🔧 Fixes to missing methods
This commit is contained in:
11
package-lock.json
generated
11
package-lock.json
generated
@@ -5,6 +5,7 @@
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "threetwo-library-service",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@root/walk": "^1.1.0",
|
||||
@@ -11628,11 +11629,6 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/string-similarity": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/string-similarity/-/string-similarity-4.0.4.tgz",
|
||||
"integrity": "sha512-/q/8Q4Bl4ZKAPjj8WerIBJWALKkaPRfrvhfF8k/B23i4nzrlRj2/go1m90In7nG/3XDSbOo0+pu6RvCTM9RGMQ=="
|
||||
},
|
||||
"node_modules/string-width": {
|
||||
"version": "4.2.2",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz",
|
||||
@@ -21892,11 +21888,6 @@
|
||||
"strip-ansi": "^5.2.0"
|
||||
}
|
||||
},
|
||||
"string-similarity": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/string-similarity/-/string-similarity-4.0.4.tgz",
|
||||
"integrity": "sha512-/q/8Q4Bl4ZKAPjj8WerIBJWALKkaPRfrvhfF8k/B23i4nzrlRj2/go1m90In7nG/3XDSbOo0+pu6RvCTM9RGMQ=="
|
||||
},
|
||||
"string-width": {
|
||||
"version": "4.2.2",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz",
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
const sharp = require("sharp");
|
||||
import { logger } from "./logger.utils";
|
||||
import { ISharpResizedImageStats } from "threetwo-ui-typings";
|
||||
const imghash = require("imghash");
|
||||
const leven = require("leven");
|
||||
import { isNull, reject } from "lodash";
|
||||
|
||||
export const extractMetadataFromImage = async (
|
||||
imageFilePath: string
|
||||
@@ -35,3 +38,20 @@ export const resizeImage = async (
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const calculateLevenshteinDistance = async (
|
||||
imagePath1: string,
|
||||
imagePath2: string
|
||||
): Promise<Record<string, unknown>> => {
|
||||
console.log("AGANTUK", imagePath1)
|
||||
const hash1 = await imghash.hash(imagePath1);
|
||||
const hash2 = await imghash.hash(imagePath2);
|
||||
console.log("HASHISH", hash1)
|
||||
if (!isNull(hash1) && !isNull(hash2)) {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve({ levenshteinDistance: leven(hash1, hash2) });
|
||||
});
|
||||
} else {
|
||||
reject("Can't calculate the Levenshtein distance")
|
||||
}
|
||||
};
|
||||
|
||||
@@ -31,7 +31,7 @@ SOFTWARE.
|
||||
* Initial: 2021/07/29 Rishi Ghan
|
||||
*/
|
||||
|
||||
import { each, map, isUndefined, isNull, assign } from "lodash";
|
||||
import { each, isNull } from "lodash";
|
||||
import stringSimilarity from "string-similarity";
|
||||
import https from "https";
|
||||
import { createWriteStream } from "fs";
|
||||
|
||||
Reference in New Issue
Block a user