🔧 Fixes to missing methods

This commit is contained in:
2021-09-06 23:21:33 -07:00
parent f5319807be
commit c7d431343d
3 changed files with 22 additions and 11 deletions

View File

@@ -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")
}
};

View File

@@ -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";