@@ -49,16 +49,21 @@ def ui_settings_callback():
49
49
report_exception (c , 'ui_settings_callback' )
50
50
51
51
52
+ def image_saved_callback (image , p , fullfn , txt_fullfn ):
53
+ for c in callbacks_image_saved :
54
+ try :
55
+ c .callback (image , p , fullfn , txt_fullfn )
56
+ except Exception :
57
+ report_exception (c , 'image_saved_callback' )
58
+
59
+
52
60
def add_callback (callbacks , fun ):
53
61
stack = [x for x in inspect .stack () if x .filename != __file__ ]
54
62
filename = stack [0 ].filename if len (stack ) > 0 else 'unknown file'
55
63
56
64
callbacks .append (ScriptCallback (filename , fun ))
57
65
58
66
59
- def image_saved_callback (image , p , fullfn , txt_fullfn ):
60
- for callback in callbacks_image_saved :
61
- callback (image , p , fullfn , txt_fullfn )
62
67
63
68
def on_model_loaded (callback ):
64
69
"""register a function to be called when the stable diffusion model is created; the model is
@@ -82,9 +87,14 @@ def on_ui_tabs(callback):
82
87
def on_ui_settings (callback ):
83
88
"""register a function to be called before UI settings are populated; add your settings
84
89
by using shared.opts.add_option(shared.OptionInfo(...)) """
85
- callbacks_ui_settings . append ( callback )
90
+ add_callback ( callbacks_ui_settings , callback )
86
91
87
92
88
93
def on_save_imaged (callback ):
89
- """register a function to call after modules.images.save_image is called returning same values, original image and p """
90
- callbacks_image_saved .append (callback )
94
+ """register a function to be called after modules.images.save_image is called.
95
+ The callback is called with three arguments:
96
+ - p - procesing object (or a dummy object with same fields if the image is saved using save button)
97
+ - fullfn - image filename
98
+ - txt_fullfn - text file with parameters; may be None
99
+ """
100
+ add_callback (callbacks_image_saved , callback )
0 commit comments