photoshop action support

This commit is contained in:
zombieyang
2025-04-27 21:56:19 +08:00
parent 9316dbf311
commit a6d8c94aca
8 changed files with 83 additions and 6 deletions
+40
View File
@@ -525,6 +525,45 @@ def define_comfyui_nodes(sdpppServer):
return (res_text,)
class RunPhotoshopActionNode:
RETURN_TYPES = ("DOCUMENT",)
RETURN_NAMES = ("document",)
FUNCTION = "action"
CATEGORY = "SD-PPP"
OUTPUT_NODE = True
@classmethod
def IS_CHANGED(self, **kwargs):
return np.random.rand()
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"document": ("DOCUMENT", {"default": None, "sdppp_type": "DOCUMENT"}),
"action_set": ("STRING", {"default": "", "sdppp_type": "STRING"}),
"action": ("STRING", {"default": "", "sdppp_type": "STRING"}),
},
"optional": SDPPPOptional({}, {
"sdppp": ("STRING", {"default": ""})
})
}
def action(self, document, 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'],
action_set=action_set,
action=action
), True)
return (document, )
# class SDPPPSettingsNode:
# RETURN_TYPES = ()
# FUNCTION = "action"
@@ -550,5 +589,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 Settings': SDPPPSettingsNode,
}
+12 -1
View File
@@ -131,4 +131,15 @@ class ProtocolPhotoshop:
}
})
return result
@classmethod
async def run_photoshop_action(cls, instance_id, document_identify, action_set, action):
ppp_instance = cls.sdpppServer.ppp_instances[instance_id]
result = await protocol_call(ppp_instance, 'B_photoshop', data={
'action': 'runPhotoshopAction',
'params': {
'action_set': action_set,
'action': action
}
})
return result
+3 -1
View File
@@ -27,7 +27,9 @@ class SDPPP:
self.sio = socketio.AsyncServer(
async_mode='aiohttp',
cors_allowed_origins="*",
max_http_buffer_size=524288000
max_http_buffer_size=524288000,
ping_interval=60,
ping_timeout=50
)
self.sio.attach(
PromptServer.instance.app,
@@ -147,4 +147,12 @@ export class GetDocumentNode extends SDPPPNodeWithInput implements NodeWithDocum
this.psdWidget.label = i18n('save .psd to this workflow')
}
}
}
}
export class RunPhotoshopActionNode extends SDPPPNodeWithInput {
async update() {
super.update();
this.node.inputs.forEach((i: any) => i.label = i18n(i.name));
this.node.outputs.forEach((i: any) => i.label = i18n(i.name));
}
}
@@ -1,6 +1,6 @@
import i18n from "../../../../src/common/i18n.mts";
import { GetImageFromLayerNode, SendImageToLayerNode } from "../comfy-nodes/legacy-nodes.mjs";
import { GetDocumentNode, GetLayerNode, GetLayersInGroupNode, GetLinkedLayersNode, GetSelectionNode, GetTextFromLayerNode, ParseLayerInfoNode, SendTextToLayerNode } from "../comfy-nodes/nodes.mjs";
import { GetDocumentNode, GetLayerNode, GetLayersInGroupNode, GetLinkedLayersNode, GetSelectionNode, GetTextFromLayerNode, ParseLayerInfoNode, RunPhotoshopActionNode, SendTextToLayerNode } from "../comfy-nodes/nodes.mjs";
import { SDPPPNode } from "../comfy-nodes/SDPPPNode.mjs";
import { SDPPPNodeWithInput } from "../comfy-nodes/SDPPPNodeWithInput.mjs";
declare const comfyAPI: any;
@@ -16,6 +16,7 @@ const SDPPPNodeList = {
'SDPPP Get Layer By ID': GetLayerNode,
'SDPPP Get Document': GetDocumentNode,
'SDPPP Get Selection': GetSelectionNode,
'SDPPP Run Photoshop Action': RunPhotoshopActionNode,
// 'SDPPP Settings': SDPPPSettingsNode,
}
export const ComfyNodeDefList: Record<any, any> = {} as any
Submodule typescripts/modules/photoshop-internal updated: 1a240fbc73...17255469f3
+4 -1
View File
@@ -38,7 +38,7 @@ export default {
'SDPPP Get Image From Photoshop': 'SDPPP从PS获取图像(GetImageFromPhotoshop)',
'SDPPP Send Images To Photoshop': 'SDPPP发送图像到PS(SendImagesToPhotoshop)',
'SDPPP Send Text To Layer': 'SDPPP发送文本到图层(SendTextToLayer)',
'SDPPP Settings': 'SDPPP设置/杂项(Settings/Misc)',
'SDPPP Run Photoshop Action': 'SDPPP运行PS Action(RunPhotoshopAction)',
// comfy widget/input
'download PS plugin (.ccx)': '下载 Photoshop 插件 (.ccx)',
@@ -171,6 +171,8 @@ export default {
'Workflow list loading failed: {0}': '工作流列表加载失败: {0}',
'Please register a user in ComfyUI': '请在 ComfyUI 中注册一个用户',
'GetSelection need Photoshop version 25+': 'GetSelection 需要 Photoshop 25+ 版本',
'Action {0} not found': 'Action {0} 未找到',
'Action set {0} not found': 'ActionSet {0} 未找到',
// photoshop modal state
'create document for sent images': '给发送的图片创建文档',
@@ -182,6 +184,7 @@ export default {
'sdppp extract PSD': 'sdppp 导入 PSD',
'sdppp get PSD': 'sdppp 获取 PSD',
'set text to layer': '设置图层的文本',
'sdppp Run Photoshop Action': 'sdppp 运行 Photoshop Action',
// photoshop dialog/widget
'{0} wants to extract a PSD file to Photoshop, are you sure?': '{0} 想要释放一个.psd文件到Photoshop,确定吗?',
@@ -141,6 +141,17 @@ export interface LayerReducerActions {
}
}
// =========== runPhotoshopAction Interfaces ===========
export interface RunPhotoshopActionActions {
params: {
action_set: string,
action: string
},
result: {
success: boolean
}
}
// Main interface that aggregates all action types
export interface PhotoshopCalleeActions {
psd: PSDActions;
@@ -153,6 +164,7 @@ export interface PhotoshopCalleeActions {
getDocumentInfo: getDocumentInfoActions;
getLinkedLayers: LayerReducerActions;
getLayersInGroup: LayerReducerActions;
runPhotoshopAction: RunPhotoshopActionActions;
}
// // PhotoshopCaller actions interface (referenced in PhotoshopCallee)