Compare commits

...

2 Commits

Author SHA1 Message Date
root
7361dc6f1f Merge branch 'main' of https://git.kmpr.at/kamp/SimilarImages into main 2022-10-28 11:29:14 +02:00
root
ea244ce76c added API handling #5 2022-10-28 11:28:54 +02:00
3 changed files with 7 additions and 3 deletions

View File

@ -3,6 +3,7 @@ import imagehash
import os
import numpy as np
import csv
import requests
def writeCSV(i1, i2):
with open("duplicates.csv", "a") as file:
@ -15,7 +16,7 @@ class DuplicateRemover:
self.dirname = dirname
self.hash_size = hash_size
def find_duplicates(self, verbose=True, exportCSV=True):
def find_duplicates(self, verbose=True, exportCSV=False, exportAPI=True):
"""
Find and Delete Duplicates
"""
@ -36,6 +37,8 @@ class DuplicateRemover:
print("Duplicate {} \nfound for Image {}!\n".format(os.path.join(path,image),os.path.join(path,hashes[temp_hash])))
if exportCSV:
writeCSV(os.path.join(path,image), os.path.join(path,hashes[temp_hash]))
if exportAPI:
requests.post('http://your-server.domain/duplicate_api.php?insertDuplicate', json={"file1":os.path.join(path,image),"file2":os.path.join(path,hashes[temp_hash])})
duplicates.append(os.path.join(path,image))
else:
hashes[temp_hash] = os.path.join(path,image)

View File

@ -1,6 +1,6 @@
from DuplicateRemover import DuplicateRemover
dirname = "images"
dirname = "/image/path/"
# Remove Duplicates
dr = DuplicateRemover(dirname)

View File

@ -4,3 +4,4 @@ Pillow==8.1.2
PyWavelets==1.1.1
scipy==1.6.2
six==1.15.0
requests