From b89285b91700f129c105cbbcd9c6a5e1639c82cb Mon Sep 17 00:00:00 2001 From: 0O0o0oOoO00 <11174151+0O0o0oOoO00@users.noreply.github.com> Date: Fri, 25 Apr 2025 14:34:11 +0800 Subject: [PATCH] fix: manually register PngImagePlugin for pre init --- alas.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/alas.py b/alas.py index 72391422a..eee691171 100644 --- a/alas.py +++ b/alas.py @@ -25,7 +25,22 @@ class AzurLaneAutoScript: AutoRestart_AttemptsToRestart = 0 AutoRestart_NotifyWhenAutoRestart = False + def pre_init(self): + from PIL import Image + Image.init() + + # Manually register PngImagePlugin + from PIL import PngImagePlugin + Image.register_open(PngImagePlugin.PngImageFile.format, PngImagePlugin.PngImageFile, PngImagePlugin._accept) + Image.register_save(PngImagePlugin.PngImageFile.format, PngImagePlugin._save) + Image.register_save_all(PngImagePlugin.PngImageFile.format, PngImagePlugin._save_all) + + Image.register_extensions(PngImagePlugin.PngImageFile.format, [".png", ".apng"]) + + Image.register_mime(PngImagePlugin.PngImageFile.format, "image/png") + def __init__(self, config_name='alas'): + self.pre_init() logger.hr('Start', level=0) self.config_name = config_name # Skip first restart