ComfyUi metadata extraction

Hi. I have lots of AI generated images from the node based ComfyUI image generation software, When you save a .png file it includes the workflow in the image somehow. I would like to batch process these images and extract the workflows into .json files, whilst also removing them from the image if that’s possible. I had a play with retrobatch2 pro, but extracting the metadata did not seem to pick up this workflow data. I may be doing something wrong though, as I’m very new to the software. It was recommended by Andy Ihnatko on Macbreak Weekly recently.

Hello, and welcome.

Can you send a sample of one of these PNG images to support@flyingmeat.com? I’m curious where in the metadata they are stuffing the workflow.

No problem, email sent.

Thanks for sending that file.

There’s no way to extract the data from the PNG with Retrobatch directly, but if you install exiftool, you can get it out with the following commands:

exiftool -b -Workflow filename.png > workflow.json
exiftool -b -Prompt filename.png > prompt.json

I tried that out, and that worked pretty well. You could use the Shell Script node in to call this, but things get a little complicated with names.

This is something that Retrobatch should be able to do natively though. I’ll see what I can do in a future release.

OK, thanks for looking into this. I will try exiftool and have a play. I might even ask Deepseek to come up with some code for me. I for one, welcome our silicon overlords…

…some hours later. I have mackled together a script that will remove the metadata from my .png images and save .json files containing it. Unfortunately, the resultant .json files are not readable by ComfyUI in the way that .json files from exported workflows are. I don’t know enough about the workings of these things to get any further, so I’ll be satisfied with what I have so far.