chrisgoringe / cg-image-picker

189 stars 13 forks source link

[FEATURE REQUEST] Support API for image picker #112

Open Arthur-xu opened 2 weeks ago

Arthur-xu commented 2 weeks ago

Hi Chris, thank you for clarification here. I'm wondering is it possible to implement this feature in cg-image-picker?

Currently, we're using comfyui api to process workflow, including this image chooser. But seems like cg-image-picker doesn't support API as of now.

chrisgoringe commented 2 weeks ago

I've not used the API, so I'll need to work through this with you. I think all the pieces are there...

When the chooser executes, it sends a message (see line 77 of image_chooser_preview.py) with type early-image-handler, and a dictionary of the id, and a list of images in the same format as the built in preview node. Hopefully your client can listen for that message and retrieve the images.

The node then waits for you to send a message back. This is done by a POST to /image_chooser_message, with the node id (or -1, meaning any/all) and a str message which can be:

You can also send __start__ at the start of a run, which clears the message queue

LMK if you need more... and if you get it working I'd love to share the code!