This commit is contained in:
leafiy
2025-11-11 09:52:14 +08:00
parent 8b439fbd1e
commit 6d01a6f2d2
3 changed files with 20 additions and 17 deletions
+4 -3
View File
@@ -31,9 +31,10 @@ matches what you would get when replacing the layer inside Photoshop.
## Usage
1. Place PSD/PSB mockups under `ComfyUI/input/psd` (or pass an absolute path).
2. Use **PSD File Upload** (or the `psd_file` input on **PSD Mockup Embedder**)
and click the built-in “choose PSD to upload” button. The frontend script will
upload the file to `ComfyUI/input` and automatically select it for you.
2. Use **PSD File Upload** and click the built-in “choose PSD to upload” button.
Connect its output directly into the `psd_path` input of **PSD Mockup
Embedder** (or Inspector). The frontend script uploads to `ComfyUI/input`
and automatically feeds the resulting path through the link.
3. Load your artwork with any stock `Load Image` (or `Upload Image`) node and
connect its `IMAGE` output to the embedder. Leave `smart_object_names`
empty to target the first smart object automatically, or pass a
+15 -13
View File
@@ -256,17 +256,15 @@ def _save_png(image: Image.Image, psd_path: str) -> str:
class PSDFileUploader:
@classmethod
def INPUT_TYPES(cls):
psd_files = _list_input_files(ALLOWED_PSD_EXTENSIONS)
if not psd_files:
psd_files = ["<upload or pick PSD>"]
return {
"required": {
"psd_file": (
psd_files,
"STRING",
{
"file_upload": True,
"file_upload_types": ["psd", "psb"],
"tooltip": "Click the upload icon to add a PSD/PSB into ComfyUI/input",
"default": "",
"multiline": False,
"placeholder": "Upload or paste a PSD path",
"tooltip": "Use the upload button to select a PSD/PSB or paste a path manually",
},
)
}
@@ -312,12 +310,16 @@ class PSDSmartObjectInspector:
class PSDMockupEmbedder:
@classmethod
def INPUT_TYPES(cls):
psd_files = _list_input_files(ALLOWED_PSD_EXTENSIONS)
if not psd_files:
psd_files = ["<upload PSD via ⬆ icon>"]
return {
"required": {
"psd_file": (psd_files,),
"psd_path": (
"STRING",
{
"default": "",
"forceInput": True,
"tooltip": "Connect PSD File Upload or provide an absolute path",
},
),
"mockup_image": ("IMAGE",),
},
"optional": {
@@ -332,11 +334,11 @@ class PSDMockupEmbedder:
def apply(
self,
psd_file: str,
psd_path: str,
mockup_image,
smart_object_names: str = "",
):
resolved_psd = _resolve_input_path(psd_file, ALLOWED_PSD_EXTENSIONS)
resolved_psd = _resolve_input_path(psd_path, ALLOWED_PSD_EXTENSIONS)
psd = PSDImage.open(resolved_psd)
source_image = _tensor_to_pil(mockup_image)
if source_image is None:
+1 -1
View File
@@ -1,7 +1,7 @@
import { app } from "../../../scripts/app.js";
import { api } from "../../../scripts/api.js";
const PSD_NODE_CLASSES = ["PSDFileUploader", "PSDMockupEmbedder", "PSDSmartObjectInspector"];
const PSD_NODE_CLASSES = ["PSDFileUploader", "PSDSmartObjectInspector"];
const ACCEPT_EXTENSIONS = [".psd", ".psb"];
function uploadPSDFile(file, node, onProgress) {