From 7caccb11fa99a24f0f298f6f671daf4f3b8ff145 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Fri, 25 Aug 2023 00:01:29 +1000 Subject: [PATCH] fix(backend): fix workflow not saving to image --- invokeai/app/services/image_file_storage.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/invokeai/app/services/image_file_storage.py b/invokeai/app/services/image_file_storage.py index ca2a117bd7..e80c6adbab 100644 --- a/invokeai/app/services/image_file_storage.py +++ b/invokeai/app/services/image_file_storage.py @@ -119,15 +119,13 @@ class DiskImageFileStorage(ImageFileStorageBase): pnginfo = PngImagePlugin.PngInfo() - if metadata is not None and workflow is not None: - if metadata is not None: - pnginfo.add_text("invokeai_metadata", json.dumps(metadata)) - if workflow is not None: - pnginfo.add_text("invokeai_workflow", workflow) - else: - # For uploaded images, we want to retain metadata. PIL strips it on save; manually add it back - for item_name, item in image.info.items(): - pnginfo.add_text(item_name, item) + if metadata is not None: + pnginfo.add_text("invokeai_metadata", json.dumps(metadata)) + if workflow is not None: + pnginfo.add_text("invokeai_workflow", workflow) + # For uploaded images, we want to retain metadata. PIL strips it on save; manually add it back + for item_name, item in image.info.items(): + pnginfo.add_text(item_name, item) image.save(image_path, "PNG", pnginfo=pnginfo)