run ps action optimize

This commit is contained in:
zombieyang
2025-05-09 09:12:03 +08:00
parent 718f3e856b
commit 21127cbbb2
6 changed files with 33 additions and 23 deletions
+15 -12
View File
@@ -509,9 +509,10 @@ def define_comfyui_nodes(sdpppServer):
return (res_text,)
class RunPhotoshopActionNode:
RETURN_TYPES = ("DOCUMENT",)
RETURN_NAMES = ("document",)
class SelectLayerAndRunPSActionNode:
RETURN_TYPES = ("LAYER",)
RETURN_NAMES = ("layer_or_group",)
INPUT_IS_LIST = False
FUNCTION = "action"
CATEGORY = "SD-PPP"
OUTPUT_NODE = True
@@ -524,7 +525,7 @@ def define_comfyui_nodes(sdpppServer):
def INPUT_TYPES(cls):
return {
"required": {
"document": ("DOCUMENT", {"default": None, "sdppp_type": "DOCUMENT"}),
"layer_or_group": ("LAYER", {"default": None, "sdppp_type": "LAYER"}),
"action_set": ("STRING", {"default": "", "sdppp_type": "STRING"}),
"action": ("STRING", {"default": "", "sdppp_type": "STRING"}),
},
@@ -533,17 +534,19 @@ def define_comfyui_nodes(sdpppServer):
})
}
def action(self, document, action_set, action, **kwargs):
def action(self, layer_or_group, action_set, action, **kwargs):
sdpppServer.has_ps_instance(throw_error=True)
call_async_func_in_server_thread(ProtocolPhotoshop.run_photoshop_action(
instance_id=document['instance_id'],
document_identify=document['identify'],
start_time = time.time()
result = call_async_func_in_server_thread(ProtocolPhotoshop.run_photoshop_action(
instance_id=layer_or_group['document']['instance_id'],
document_identify=layer_or_group['document']['identify'],
layer_identify=layer_or_group['layer_identify'],
action_set=action_set,
action=action
), True)
return (document, )
))
print(result)
return (layer_or_group, )
@@ -573,6 +576,6 @@ def define_comfyui_nodes(sdpppServer):
# 'SDPPP Send Text To Layer': SendTextToLayerNode,
'SDPPP Get Selection': GetSelectionNode,
'SDPPP Parse Layer Info': ParseLayerInfoNode,
'SDPPP Run Photoshop Action': RunPhotoshopActionNode,
'SDPPP Run PS Action On Layer': SelectLayerAndRunPSActionNode,
# 'SDPPP Settings': SDPPPSettingsNode,
}
+5 -4
View File
@@ -153,9 +153,9 @@ def define_comfyui_nodes_legacy(sdppp):
class SendImageToPhotoshopLayerNode:
RETURN_TYPES = ("IMAGE",)
RETURN_NAMES = ("images",)
OUTPUT_IS_LIST = (True,)
RETURN_TYPES = ("LAYER",)
RETURN_NAMES = ("layer_or_group",)
OUTPUT_IS_LIST = (True, True)
OUTPUT_NODE = True
INPUT_IS_LIST = True
FUNCTION = "send_image"
@@ -237,7 +237,8 @@ def define_comfyui_nodes_legacy(sdppp):
boundaries=[p['boundary'] for p in params],
new_layer_name=sdppp_arg_item['lastOpenedWorkflow']
), True)
return (images,)
ret_layer_or_group = None if not linked_style else layer_or_group
return (ret_layer_or_group,)
class CLIPTextEncodePSRegional:
@classmethod
+5 -2
View File
@@ -133,11 +133,14 @@ class ProtocolPhotoshop:
return result
@classmethod
async def run_photoshop_action(cls, instance_id, document_identify, action_set, action):
async def run_photoshop_action(cls, instance_id, document_identify, layer_identify, action_set, action):
ppp_instance = cls.sdpppServer.ppp_instances[instance_id]
start = time.time()
result = await protocol_call(ppp_instance, 'B_photoshop', data={
'action': 'runPhotoshopAction',
'action': 'runPhotoshopActionOnLayer',
'params': {
'document_identify': document_identify,
'layer_identify': layer_identify,
'action_set': action_set,
'action': action
}