-
Notifications
You must be signed in to change notification settings - Fork 0
/
imageTester.ts
43 lines (38 loc) · 1.29 KB
/
imageTester.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { ImageEqual, ImageToVerifyBasedInBase64, ImageToVerifyBasedInData } from './types';
class ImageComparator {
static verifyByBase64 = (imagesToVerify: ImageToVerifyBasedInBase64[]): ImageEqual[] => {
const arrayOfImageEqualToReturn: ImageEqual[] = [];
for (let i = 0; i < imagesToVerify.length; i++) {
const image = imagesToVerify[i];
const auxImage: string[] = [];
imagesToVerify.forEach((v) => {
if (image.base64 === v.base64 && image.id !== v.id) {
auxImage.push(v.id);
}
});
arrayOfImageEqualToReturn.push({
id: image.id,
imagesIdsEqual: auxImage,
});
}
return arrayOfImageEqualToReturn;
};
static verifyByBytes = (imagesToVerify: ImageToVerifyBasedInData[]): ImageEqual[] => {
const arrayOfImageEqualToReturn: ImageEqual[] = [];
for (let i = 0; i < imagesToVerify.length; i++) {
const image = imagesToVerify[i];
const auxImage: string[] = [];
imagesToVerify.forEach((v) => {
if (image.data.equals(v.data) && image.id !== v.id) {
auxImage.push(v.id);
}
});
arrayOfImageEqualToReturn.push({
id: image.id,
imagesIdsEqual: auxImage,
});
}
return arrayOfImageEqualToReturn;
};
}
export default ImageComparator;