stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

add callback after image is saved

Open tsngo opened this issue 3 years ago • 3 comments

Add script callback after modules.images.save_image is called. Looking to support doing additional things to the files saved. For example: https://github.com/tsngo/stable-diffusion-webui-aesthetic-image-scorer

tsngo avatar Oct 24 '22 06:10 tsngo

If we're adding a callback here, I think it would make a lot more sense to call it just before the image is saved, and make it possible for script user to alter the image (ie if user's callback returns an image, use that for saving, if None - use original).

Do you want your extension added to wiki?

AUTOMATIC1111 avatar Oct 24 '22 07:10 AUTOMATIC1111

Ok I'll look at it later today. Would be great to add my extension to wiki when this is done.

tsngo avatar Oct 24 '22 12:10 tsngo

Maybe one callback before saving and another one after saving would be best? After saving is also useful for sending the new image to other systems or making a better ui.

fuzzytent avatar Oct 24 '22 16:10 fuzzytent

Yeah that's probably what I need to do. One before and after as I can't figure out a way to do what I need on my extension before the file is saved

tsngo avatar Oct 24 '22 20:10 tsngo

getting this error after update image

Mikian01 avatar Oct 25 '22 06:10 Mikian01

Failed to run Error loading script: image_scorer.py Traceback (most recent call last): File "F:\ProgramData\StableDiffusion\stable-diffusion-webui\modules\scripts.py", line 159, in load_scripts exec(compiled, module.dict) File "F:\ProgramData\StableDiffusion\stable-diffusion-webui\extensions\aesthetic-image-scorer\scripts\image_scorer.py", line 130, in script_callbacks.on_before_image_saved(on_before_image_saved) AttributeError: module 'modules.script_callbacks' has no attribute 'on_before_image_saved'

yxmline avatar Oct 25 '22 06:10 yxmline

getting this error after update image

same error

tsound97 avatar Oct 25 '22 09:10 tsound97