feat: embed workflow in generated PNG metadata#225
Conversation
Drop --disable-metadata from the comfyui launch and forward extra_pnginfo.workflow alongside the prompt in the /prompt payload. This is what ComfyUI's Save Image node looks at to embed the "workflow" key in PNG metadata. Without both, generated PNGs cannot be dragged back into the editor to recover the source workflow. Refs #139
|
Validation status update
The code change is correct and the crystools side-effect is verified. The final PNG-metadata roundtrip test (decode the returned PNG with PIL and confirm I'd recommend merging this anyway and validating on the next release — the surface area is small, the diff logic checks out, and the worst case is "PNG metadata not embedded" which is the current state of |
|
Verified both changes are in the built image: ``` Both `python /comfyui/main.py` invocations are missing `--disable-metadata` ✅. And: ``` The `extra_pnginfo` payload change is in handler.py ✅. So both halves of the fix are correctly baked. End-to-end PNG embedding test (decode returned PNG and confirm `workflow` chunk) still pending a live deploy that doesn't hit the host-side infra issue I ran into earlier today. |
Summary
Closes #139.
Generated PNGs currently cannot be dragged back into ComfyUI to recover the source workflow — because the worker was suppressing PNG metadata in two places:
`extra_pnginfo.workflow` is what the `Save Image` node reads to populate the `workflow` key embedded in PNG metadata (separate from the API-format `prompt`). Without both, the round-trip from output PNG → editor workflow doesn't work.
Bonus fix: crystools NoneType crash
This PR also fixes a separate bug discovered while investigating #167. Without `extra_pnginfo` in the payload, ComfyUI-Crystools' `Save image with extra metadata` node crashes with:
```
AttributeError: 'NoneType' object has no attribute 'copy'
```
at `nodes/image.py:392` (`extra_pnginfo_new = extra_pnginfo.copy()`) when `with_workflow=True`. Reproduced on a fresh pod today; PR fixes it.
Test plan
Trade-off
Each generated PNG is now ~10–50 KB larger (workflow JSON embedded). For users who want smaller responses, they can route through `PreviewImage` instead of `Save Image`, or strip metadata client-side. Worth documenting in a follow-up.