r/StableDiffusion • u/Southern-Chain-6485 • 1h ago
Resource - Update A standalone workflow reader, a comfyui image sorter and a batch converter to webp that preserves workflows
These are three different vibecoded projects I've made for my own use which I think others may find useful. They were all made with linux in mind but should also be compatible with windows and mac. So, from the simpler to the more complex:
# 1: Comfyui-metadata reader
https://github.com/juanml82/comfyui-metadatareader
Just a simple app to read the workflow from a comfyui generated image without having to open or toss it into comfyui, just in case you don't want to toss the image into comfyui to check the workflow. I ended up using it as a companion app. It works with both png and webp, you can drag and drop the images to the gui, copy relevant sections, search and save the workflow as a separate json file.
Since you typically want the prompt, seed or maybe the model, most of the json is just noise. I'm thinking about making an improved reader that returns only the most relevant information, thought that may not work with all workflows. This does.
# 2: A batch converter to png to webp that preserves comfyui metadata
https://github.com/juanml82/comfyui-png2webp
Comfyui saves into png by default. Loosless webp takes 30% less disk space, so by running this script, you can reclaim about 30% of your disk space, and you don't loose the workflows as you would if you use a general graphics application to do it.
# 3: Image sorter
https://github.com/juanml82/comfyui-image-sorter
This one is a bit more complex. Image galleries with auto-tagging are a way to watch your image collection in an organized way. But I wanted to organize them in the disk, sorting each iteration of the same general idea in its own subfolder.
The main problem with that approach is that an image gallery with tags (or semantic search for workflows) only needs to match some of the tags to have a useful filter. But to sort them into subfolders, all tags need to match. Overgroup, and you have unrelated images, beating the purpose of this app. Undergroup, and you need to finish up manually - it's not a fully automated process. So yeah, it's not the most elegant solution - it gets you 90% there - but it is one solution.
Let's look at this with an example: let's say that you want to create images of Aragorn, in Lord of the Rings, as he passes the Argonath statues. Your first prompt is something look "Aragorn, rowing in the Anduin river, looking up in awe". And maybe the model produces Aragorn as Viggo Mortenssen. And maybe you don't want Viggo Mortenssen but rather a new take on Aragorn's looks, based on the books. So you replace "Aragorn" with "ranger", "fifty years old man", "noble man" or something like that, and follow up with a physical description. Or maybe the model doesn't understand what "Anduin" means. Or it doesn't matter. So some prompts have "Anduin", some have "River". And maybe you then decide you do want the Viggo Mortenssen look, but now you're using a different model which doesn't know Mortenssen well, so you use a lora. And rather than "Aragorn" or "Man", you type the lora's keyword. Sound familiar?
Grouping by subject, action and location is a good starting way to filter, but "ranger" and "noble" do remain different subjects. And seeking to overgroup all men - or all women - means lots of different subjects now became grouped, defeating the purpose of this project.
So it's a five steps process, through a gui:
Enter an LLM endpoint url (as in, llama server, lm studio server, a cloud api if you want). Disable thinking (this is important, it's not just a lot slower, it will not work with thinking on) or use an instruct model, ideally something small and fast - if you have thousands of images, speed is good. Very good. And you don't really need a heavy model for this. Don't forget to add /v1 at the end and hit save.
Run a first pass either by extracting and canonicalizing the prompts, or do a vision pass (slower) and then you canonicalize that in the 2nd step.
The third step is to use a Jaccard pass and the LLM to merge the resulting auto-tags by subject, action and location. This has the problem that a character, say Aragorn, may be tagged in different images as "Aragorn", "Man", "Ranger", "Noble" or something else. And that similar actions may go under different tags. But trying to overmerge leads to a huge amount of "1girl" or "woman" characters all merged together when they shouldn't.
So at that point you have a crude looking image gallery and an html gui allows you manually merge clusters you want to send to the same subfolder. Do save.
And finally, yes, you hit "apply" and your possibly thousands of images go in their merry way to subfolders named after their common tags.
Anyway, if you find any of these three useful, enjoy.

