mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-09 04:52:32 +08:00
show "clipspace/filename.png" instead of 'filename.png [clipspace]' in LoadImage/LoadImageMask
This commit is contained in:
parent
9d96b9448b
commit
66ace3b55b
7
nodes.py
7
nodes.py
@ -973,7 +973,7 @@ class LoadImage:
|
||||
input_dir = folder_paths.get_input_directory()
|
||||
input_dir = [f for f in os.listdir(input_dir) if os.path.isfile(os.path.join(input_dir, f))]
|
||||
return {"required":
|
||||
{"image": (sorted(input_dir), )},
|
||||
{"image": ("FILE_COMBO", {"base_dir": "input", "files": sorted(input_dir)}, )},
|
||||
}
|
||||
|
||||
CATEGORY = "image"
|
||||
@ -1013,9 +1013,10 @@ class LoadImageMask:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
input_dir = folder_paths.get_input_directory()
|
||||
input_dir = [f for f in os.listdir(input_dir) if os.path.isfile(os.path.join(input_dir, f))]
|
||||
return {"required":
|
||||
{"image": (sorted(os.listdir(input_dir)), ),
|
||||
"channel": (s._color_channels, ),}
|
||||
{"image": ("FILE_COMBO", {"base_dir": "input", "files": sorted(input_dir)}, ),
|
||||
"channel": (s._color_channels, ), }
|
||||
}
|
||||
|
||||
CATEGORY = "mask"
|
||||
|
||||
@ -201,6 +201,14 @@ class PromptServer():
|
||||
filename = request.rel_url.query["filename"]
|
||||
filename,output_dir = folder_paths.annotated_filepath(filename)
|
||||
|
||||
if request.rel_url.query.get("type", "input") and filename.startswith("clipspace/"):
|
||||
output_dir = folder_paths.get_clipspace_directory()
|
||||
filename = filename[10:]
|
||||
|
||||
# validation for security: prevent accessing arbitrary path
|
||||
if filename[0] == '/' or '..' in filename:
|
||||
return web.Response(status=400)
|
||||
|
||||
if output_dir is None:
|
||||
type = request.rel_url.query.get("type", "output")
|
||||
output_dir = folder_paths.get_directory_by_type(type)
|
||||
|
||||
@ -231,6 +231,11 @@ export class ComfyApp {
|
||||
if(this.widgets) {
|
||||
const index = this.widgets.findIndex(obj => obj.name === 'image');
|
||||
if(index >= 0 && filename != "") {
|
||||
const postfix = ' [clipspace]';
|
||||
if(filename.endsWith(postfix) && this.widgets[index].options.base_dir == 'input') {
|
||||
filename = "clipspace/" + filename.slice(0, filename.indexOf(postfix));
|
||||
}
|
||||
|
||||
this.widgets[index].value = filename;
|
||||
if(this.widgets_values != undefined) {
|
||||
this.widgets_values[index] = filename;
|
||||
|
||||
@ -256,6 +256,20 @@ export const ComfyWidgets = {
|
||||
}
|
||||
return { widget: node.addWidget("combo", inputName, defaultValue, () => {}, { values: type }) };
|
||||
},
|
||||
FILE_COMBO(node, inputName, inputData) {
|
||||
const base_dir = inputData[1].base_dir;
|
||||
let defaultValue = inputData[1].files[0];
|
||||
|
||||
const files = []
|
||||
for(let i in inputData[1].files) {
|
||||
files[i] = inputData[1].files[i];
|
||||
const postfix = ' [clipspace]';
|
||||
if(base_dir == 'input' && files[i].endsWith(postfix))
|
||||
files[i] = "clipspace/" + files[i].slice(0, files[i].indexOf(postfix));
|
||||
}
|
||||
|
||||
return { widget: node.addWidget("combo", inputName, defaultValue, () => {}, { base_dir:base_dir, values: files }) };
|
||||
},
|
||||
IMAGEUPLOAD(node, inputName, inputData, app) {
|
||||
const imageWidget = node.widgets.find((w) => w.name === "image");
|
||||
let uploadWidget;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user