mcmonkeyprojects / SwarmUI

SwarmUI (formerly StableSwarmUI), A Modular Stable Diffusion Web-User-Interface, with an emphasis on making powertools easily accessible, high performance, and extensibility.
MIT License
2.52k stars 220 forks source link

JPEG metadata not correctly stored so that Civitai does not recognize it #735

Open antispam2002 opened 2 weeks ago

antispam2002 commented 2 weeks ago

Your question

When generating images in JPEG format, SwarmUI writes the metadata JSON into "Comments" property which can be inspected e.g. with Windows Explorer. When uploading to Civitai, this information is ignored. BUT - if the image is once opened and saved with e.g. MS Paint, with no changes, then Civitai recognizes the prompt and other generation parameters. SwarmUI, however, cannot read the metadata from this file reporting the following error

11:13:34.916 [Warning] Error reading image metadata for file 'C:/SwarmUI/Output/local/raw/2025-04-21/0936XXX105405116.jpg': Newtonsoft.Json.JsonReaderException: Failed to parse JSON `(Invalid Characters Stripped) `: Unexpected character encountered while parsing value: ?. Path '', line 0, position 0.
   at SwarmUI.Utils.Utilities.ParseToJson(String input) in C:\SwarmUI\src\Utils\Utilities.cs:line 584
   at SwarmUI.Utils.ImageMetadataTracker.GetMetadataFor(String file, String root, Boolean starNoFolders) in C:\SwarmUI\src\Utils\ImageMetadataTracker.cs:line 326

The metadata, however, is still there, and looks - at least visually - absolutely intact. Can SwarmUI write the metadata so that it directly can be parsed by Civitai?

Logs

No response

Other

No response

mcmonkey4eva commented 2 weeks ago

It's probably the weird encoding direction thingy -- iirc there's unfortunately no "correct answer" per se for how it should be done. Rather:

So for Swarm reading the reverse order, I'll mark this as a bug to fix - for civitai, you'll have to poke them about it