Skip to content

Commit

Permalink
🐛 修复批量打码不保存图片
Browse files Browse the repository at this point in the history
  • Loading branch information
zhulinyv committed Jun 27, 2024
1 parent 920e95f commit 302388f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
11 changes: 5 additions & 6 deletions src/batch_mosaic.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@ def main(file_path, input_img, open_button, mode):
elif mode == "lines":
mosaic_lines("./output/temp.png")
logger.success("处理完成!")
if open_button:
shutil.move("./output/temp.png", f"./output/mosaic/{file_path2name(file)}")
return None, "处理完成! 图片已保存到 ./output/mosaic"
else:
os.remove("./output/_temp.png")
return "./output/temp.png", None
if open_button:
shutil.copyfile("./output/temp.png", f"./output/mosaic/{file_path2name(file)}")
else:
os.remove("./output/_temp.png")
return "./output/temp.png", "处理完成! 图片已保存到 ./output/mosaic"
8 changes: 6 additions & 2 deletions utils/imgtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,13 @@ def revert_img_info(img_path, output_dir, *args):
with Image.open(output_dir) as new_img:
new_img.save(output_dir, pnginfo=metadata)
logger.success("还原成功!")
except Exception as e:
logger.error(f"还原失败!\n{e}")
except Exception:
with Image.open(output_dir) as new_img:
new_img.save(output_dir)
logger.error("还原失败!")
else:
with Image.open(output_dir) as new_img:
new_img.save(output_dir)
logger.warning("还原图片信息操作已关闭, 如有需要请在配置项中设置 revert_info=True")


Expand Down

0 comments on commit 302388f

Please sign in to comment.