回答編集履歴
1
d
test
CHANGED
@@ -18,25 +18,27 @@
|
|
18
18
|
|
19
19
|
def File_open():
|
20
20
|
|
21
|
-
|
21
|
+
paths = tkdialog.askopenfilenames(filetypes=[(".png", "*.png")], initialdir=dir)
|
22
22
|
|
23
|
-
|
23
|
+
for img_path in paths:
|
24
24
|
|
25
|
-
ret
|
25
|
+
img = cv2.imread(img_path)
|
26
26
|
|
27
|
-
|
27
|
+
if img is None:
|
28
28
|
|
29
|
+
continue # 読み込みに失敗した場合
|
30
|
+
|
31
|
+
base_path, ext = os.path.splitext(img_path)
|
32
|
+
|
29
|
-
save_path = f"{base_path}-crop{ext}"
|
33
|
+
save_path = f"{base_path}-crop{ext}"
|
30
34
|
|
31
35
|
|
32
36
|
|
33
|
-
|
37
|
+
crop = img[80: , 80:]
|
34
38
|
|
35
|
-
|
39
|
+
cv2.imwrite(save_path, crop)
|
36
40
|
|
37
|
-
cv2.imwrite(save_path, crop)
|
38
|
-
|
39
|
-
print(f"image saved! {save_path}")
|
41
|
+
print(f"image saved! {save_path}")
|
40
42
|
|
41
43
|
|
42
44
|
|