From 35c3f52bf57cd56ec430d025ab07854b67a4e18f Mon Sep 17 00:00:00 2001 From: zombieyang Date: Sat, 27 Apr 2024 17:38:58 +0800 Subject: [PATCH] add ### to identifier speicial layer config, move static file to static/ --- comfy/__init__.py | 49 +++++------------------ comfy/{plugins => static/js}/sd-ppp.js | 0 comfy/{ => static}/plugins/sd-ppp_PS.ccx | Bin readme.md | 2 +- 4 files changed, 12 insertions(+), 39 deletions(-) rename comfy/{plugins => static/js}/sd-ppp.js (100%) rename comfy/{ => static}/plugins/sd-ppp_PS.ccx (100%) diff --git a/comfy/__init__.py b/comfy/__init__.py index bbe2a30..1392c32 100644 --- a/comfy/__init__.py +++ b/comfy/__init__.py @@ -295,10 +295,10 @@ def get_layers_str(): bounds_strs = [] if PhotoshopInstance.instance is not None: layer_strs = list(map(lambda layer: f"{layer['name']} (id:{layer['id']})", PhotoshopInstance.instance.layers)) - layer_strs.insert(0, 'Use canvas') + layer_strs.insert(0, '### Use canvas ###') bounds_strs = list(layer_strs) - bounds_strs.insert(0, 'Use selection') - bounds_strs.insert(0, 'Same as layer') + bounds_strs.insert(0, '### Use selection ###') + bounds_strs.insert(0, '### Same as layer ###') return layer_strs, bounds_strs class GetImageFromPhotoshopLayerNode: @@ -339,11 +339,11 @@ class GetImageFromPhotoshopLayerNode: layer_name_and_id_split = layer.split('(id:') id = int(layer_name_and_id_split.pop().strip()[:-1]) bounds_id = 0 - if use_layer_bounds == 'Canvas': + if use_layer_bounds == '### Canvas ###': bounds_id = 0 - elif use_layer_bounds == 'Use selection': + elif use_layer_bounds == '### Use selection ###': bounds_id = -1 - elif use_layer_bounds == 'Same as layer': + elif use_layer_bounds == '### Same as layer ###': bounds_id = id else: bounds_layer_name_and_id_split = use_layer_bounds.split('(id:') @@ -376,6 +376,7 @@ def cache_images(images): ImageCache.data[image_id] = img ret.append(image_id) return ret + class SendImageToPhotoshopLayerNode: @classmethod def VALIDATE_INPUTS(s, images): @@ -385,39 +386,12 @@ class SendImageToPhotoshopLayerNode: @classmethod def INPUT_TYPES(cls): - return { - "required": { - "images": ("IMAGE", ) - } - } - - RETURN_TYPES = () - FUNCTION = "send_image" - CATEGORY = "Photoshop" - OUTPUT_NODE = True - - def send_image(self, images): - if (PhotoshopInstance.instance is None): - raise ValueError('Photoshop is not connected') - - ret = cache_images(images) - - threading.Thread(target=lambda: asyncio.run(PhotoshopInstance.instance.send_images(image_ids=ret))).start() - return (None,) - -class SendImageToPhotoshopSetLayerNode: - @classmethod - def VALIDATE_INPUTS(s, images): - if (PhotoshopInstance.instance is None): - return 'Photoshop is not connected' - return True - - @classmethod - def INPUT_TYPES(cls): + layer_strs, bounds_strs = get_layers_str() + layer_strs.insert(0, '### New Layer ###') return { "required": { "images": ("IMAGE", ), - "layer_name": (("STRING", {"default": "COMFY RESULT"})) + "layer": (layer_strs, {"default": layer_strs[0] if len(layer_strs) > 0 else None}), } } @@ -499,7 +473,6 @@ async def get_layers(request): NODE_CLASS_MAPPINGS = { 'Get Image From Photoshop Layer': GetImageFromPhotoshopLayerNode, 'Send Images To Photoshop': SendImageToPhotoshopLayerNode, - 'Send Images To Photoshop Set Layer': SendImageToPhotoshopSetLayerNode, 'Image Times Opacity': ImageTimesOpacity, 'Mask Times Opacity': MaskTimesOpacity, } @@ -510,5 +483,5 @@ NODE_DISPLAY_NAME_MAPPINGS = { 'Image Times Opacity': 'Image times opacity', 'Mask Times Opacity': 'Mask times opacity', } -WEB_DIRECTORY = 'comfy/plugins' +WEB_DIRECTORY = 'comfy/static' __all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS', 'WEB_DIRECTORY'] \ No newline at end of file diff --git a/comfy/plugins/sd-ppp.js b/comfy/static/js/sd-ppp.js similarity index 100% rename from comfy/plugins/sd-ppp.js rename to comfy/static/js/sd-ppp.js diff --git a/comfy/plugins/sd-ppp_PS.ccx b/comfy/static/plugins/sd-ppp_PS.ccx similarity index 100% rename from comfy/plugins/sd-ppp_PS.ccx rename to comfy/static/plugins/sd-ppp_PS.ccx diff --git a/readme.md b/readme.md index 662b207..295c9b8 100644 --- a/readme.md +++ b/readme.md @@ -7,7 +7,7 @@ 2. install Photoshop plugin 1. by CXX: - 1. download `http:///extensions/sd-ppp/sd-ppp_PS.ccx`. + 1. download `http:///extensions/sd-ppp/plugins/sd-ppp_PS.ccx`. 2. double click the `.ccx` file. Or place it into photoshop's plugin directory. 2. by UXP develop Tool (you can debug the code this way): 1. clone this repository