Repository navigation
Expand file tree
/
Copy pathduplicate_delete.py
More file actions
58 lines (44 loc) · 1.74 KB
/
Copy pathduplicate_delete.py
File metadata and controls
58 lines (44 loc) · 1.74 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import os
import time
from PIL import Image
def compare_images(input_image, output_image):
if input_image.size != output_image.size:
return False
rows, cols = input_image.size
for row in range(rows):
for col in range(cols):
input_pixel = input_image.getpixel((row, col))
output_pixel = output_image.getpixel((row, col))
if input_pixel != output_pixel:
return False
return True
for sep in os.listdir():
# print(sep, end="\t")
if sep == "downloads":
for folder in os.listdir(sep):
# if folder == "유리잔":
# print(folder, end=" / ")
middle = os.path.join(sep, folder)
files = os.listdir(middle)
# print(len(files))
# if len(files) > 1600:
# print(len(files), end=" : ")
for i in range(len(files) - 1):
# print(files[i], end=" / ")
input_image = os.path.join(middle, files[i])
if not os.path.exists(input_image):
continue
for j in range(i + 1, len(files)):
# print(files[j], end=" / ")
output_image = os.path.join(middle, files[j])
if not os.path.exists(output_image):
continue
# print(input_image, output_image, sep=" / ")
inputs = Image.open(input_image)
outputs = Image.open(output_image)
if compare_images(inputs, outputs):
os.remove(output_image)
time.sleep(2)
print(i, end="th")
print(folder + " finish")
print(sep + " clear", sep="\n")