mirror of
https://github.com/Comfy-Org/ComfyUI-Manager.git
synced 2025-12-23 05:10:48 +08:00
added support for previewimage
This commit is contained in:
parent
c6337a19a8
commit
7a79cf7d60
15
__init__.py
15
__init__.py
@ -1287,12 +1287,14 @@ async def share_art(request):
|
|||||||
output_to_share = potential_outputs[0]
|
output_to_share = potential_outputs[0]
|
||||||
|
|
||||||
assert output_to_share['type'] in ('image', 'output')
|
assert output_to_share['type'] in ('image', 'output')
|
||||||
|
|
||||||
output_dir = folder_paths.get_output_directory()
|
output_dir = folder_paths.get_output_directory()
|
||||||
|
|
||||||
if output_to_share['type'] == 'image':
|
if output_to_share['type'] == 'image':
|
||||||
asset_filename = output_to_share['image']['filename']
|
asset_filename = output_to_share['image']['filename']
|
||||||
asset_subfolder = output_to_share['image']['subfolder']
|
asset_subfolder = output_to_share['image']['subfolder']
|
||||||
|
|
||||||
|
if output_to_share['image']['type'] == 'temp':
|
||||||
|
output_dir = folder_paths.get_temp_directory()
|
||||||
else:
|
else:
|
||||||
asset_filename = output_to_share['output']['filename']
|
asset_filename = output_to_share['output']['filename']
|
||||||
asset_subfolder = output_to_share['output']['subfolder']
|
asset_subfolder = output_to_share['output']['subfolder']
|
||||||
@ -1316,18 +1318,28 @@ async def share_art(request):
|
|||||||
json={
|
json={
|
||||||
"assetFileName": asset_filename,
|
"assetFileName": asset_filename,
|
||||||
"assetFileType": assetFileType,
|
"assetFileType": assetFileType,
|
||||||
|
"workflowJsonFileName" : 'workflow.json',
|
||||||
|
"workflowJsonFileType" : 'application/json',
|
||||||
|
|
||||||
},
|
},
|
||||||
) as resp:
|
) as resp:
|
||||||
assert resp.status == 200
|
assert resp.status == 200
|
||||||
presigned_urls_json = await resp.json()
|
presigned_urls_json = await resp.json()
|
||||||
assetFilePresignedUrl = presigned_urls_json["assetFilePresignedUrl"]
|
assetFilePresignedUrl = presigned_urls_json["assetFilePresignedUrl"]
|
||||||
assetFileKey = presigned_urls_json["assetFileKey"]
|
assetFileKey = presigned_urls_json["assetFileKey"]
|
||||||
|
workflowJsonFilePresignedUrl = presigned_urls_json["workflowJsonFilePresignedUrl"]
|
||||||
|
workflowJsonFileKey = presigned_urls_json["workflowJsonFileKey"]
|
||||||
|
|
||||||
# upload asset
|
# upload asset
|
||||||
async with aiohttp.ClientSession(trust_env=True, connector=aiohttp.TCPConnector(verify_ssl=False)) as session:
|
async with aiohttp.ClientSession(trust_env=True, connector=aiohttp.TCPConnector(verify_ssl=False)) as session:
|
||||||
async with session.put(assetFilePresignedUrl, data=open(asset_filepath, "rb")) as resp:
|
async with session.put(assetFilePresignedUrl, data=open(asset_filepath, "rb")) as resp:
|
||||||
assert resp.status == 200
|
assert resp.status == 200
|
||||||
|
|
||||||
|
# upload workflow json
|
||||||
|
async with aiohttp.ClientSession(trust_env=True, connector=aiohttp.TCPConnector(verify_ssl=False)) as session:
|
||||||
|
async with session.put(workflowJsonFilePresignedUrl, data=json.dumps(prompt['workflow']).encode('utf-8')) as resp:
|
||||||
|
assert resp.status == 200
|
||||||
|
|
||||||
# make a POST request to /api/upload_workflow with form data key values
|
# make a POST request to /api/upload_workflow with form data key values
|
||||||
async with aiohttp.ClientSession(trust_env=True, connector=aiohttp.TCPConnector(verify_ssl=False)) as session:
|
async with aiohttp.ClientSession(trust_env=True, connector=aiohttp.TCPConnector(verify_ssl=False)) as session:
|
||||||
form = aiohttp.FormData()
|
form = aiohttp.FormData()
|
||||||
@ -1336,6 +1348,7 @@ async def share_art(request):
|
|||||||
form.add_field("source", "comfyui_manager")
|
form.add_field("source", "comfyui_manager")
|
||||||
form.add_field("assetFileKey", assetFileKey)
|
form.add_field("assetFileKey", assetFileKey)
|
||||||
form.add_field("assetFileType", assetFileType)
|
form.add_field("assetFileType", assetFileType)
|
||||||
|
form.add_field("workflowJsonFileKey", workflowJsonFileKey)
|
||||||
form.add_field("sharedWorkflowWorkflowJsonString", json.dumps(prompt['workflow']))
|
form.add_field("sharedWorkflowWorkflowJsonString", json.dumps(prompt['workflow']))
|
||||||
form.add_field("sharedWorkflowPromptJsonString", json.dumps(prompt['output']))
|
form.add_field("sharedWorkflowPromptJsonString", json.dumps(prompt['output']))
|
||||||
form.add_field("shareWorkflowCredits", credits)
|
form.add_field("shareWorkflowCredits", credits)
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import { api } from "../../scripts/api.js"
|
|||||||
import { ComfyDialog, $el } from "../../scripts/ui.js";
|
import { ComfyDialog, $el } from "../../scripts/ui.js";
|
||||||
|
|
||||||
export const SUPPORTED_OUTPUT_NODE_TYPES = [
|
export const SUPPORTED_OUTPUT_NODE_TYPES = [
|
||||||
|
"PreviewImage",
|
||||||
"SaveImage",
|
"SaveImage",
|
||||||
"VHS_VideoCombine",
|
"VHS_VideoCombine",
|
||||||
"ADE_AnimateDiffCombine",
|
"ADE_AnimateDiffCombine",
|
||||||
@ -31,6 +32,17 @@ export function getPotentialOutputsAndOutputNodes(nodes) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (node.type === "PreviewImage") {
|
||||||
|
potential_output_nodes.push(node);
|
||||||
|
|
||||||
|
// check if node has an 'images' array property
|
||||||
|
if (node.hasOwnProperty("images") && Array.isArray(node.images)) {
|
||||||
|
// iterate over the images array and add each image to the potential_outputs array
|
||||||
|
for (let j = 0; j < node.images.length; j++) {
|
||||||
|
potential_outputs.push({ "type": "image", "image": node.images[j], "title": node.title });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (node.type === "VHS_VideoCombine") {
|
else if (node.type === "VHS_VideoCombine") {
|
||||||
potential_output_nodes.push(node);
|
potential_output_nodes.push(node);
|
||||||
|
|
||||||
@ -503,7 +515,7 @@ export class ShareDialog extends ComfyDialog {
|
|||||||
}, potential_outputs.map((output, index) => {
|
}, potential_outputs.map((output, index) => {
|
||||||
const radio_button = $el("input", { type: 'radio', name: "selectOutputImages", value: index, required: index === 0 }, [])
|
const radio_button = $el("input", { type: 'radio', name: "selectOutputImages", value: index, required: index === 0 }, [])
|
||||||
let radio_button_img;
|
let radio_button_img;
|
||||||
if (output.type === "image") {
|
if (output.type === "image" || output.type === "temp") {
|
||||||
radio_button_img = $el("img", { src: `/view?filename=${output.image.filename}&subfolder=${output.image.subfolder}&type=${output.image.type}`, style: { width: "auto", height: "100px" } }, []);
|
radio_button_img = $el("img", { src: `/view?filename=${output.image.filename}&subfolder=${output.image.subfolder}&type=${output.image.type}`, style: { width: "auto", height: "100px" } }, []);
|
||||||
} else if (output.type === "output") {
|
} else if (output.type === "output") {
|
||||||
radio_button_img = $el("img", { src: output.output.value, style: { width: "auto", height: "100px" } }, []);
|
radio_button_img = $el("img", { src: output.output.value, style: { width: "auto", height: "100px" } }, []);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user