pull/41/head
toshiaki1729 2023-02-18 16:24:32 +09:00
parent 7123254545
commit ddde7b756e
1 changed files with 4 additions and 1 deletions

View File

@ -393,6 +393,7 @@ class DatasetTagEditor:
try:
if os.path.exists(img_path) and os.path.isfile(img_path):
if img_path in self.images:
self.images[img_path].close()
del self.images[img_path]
os.remove(img_path)
self.dataset.remove_by_path(img_path)
@ -434,10 +435,12 @@ class DatasetTagEditor:
dst_path = os.path.join(dest_dir, os.path.basename(img_path))
if os.path.exists(img_path) and os.path.isfile(img_path):
if img_path in self.images:
img = self.images[img_path]
self.images[img_path].close()
del self.images[img_path]
os.replace(img_path, dst_path)
self.dataset.remove_by_path(img_path)
img = Image.open(dst_path)
img.already_saved_as = dst_path
self.images[dst_path] = img
print(f'[tag-editor] Moved {img_path} -> {dst_path}')
except Exception as e: