mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-14 23:42:35 +08:00
accepting png files too now
This commit is contained in:
parent
2528135dbe
commit
93b6a5a77d
@ -1,4 +1,5 @@
|
|||||||
import { api } from "./api.js"
|
import { api } from "./api.js"
|
||||||
|
import { getPngMetadata } from "./pnginfo.js";
|
||||||
|
|
||||||
function getNumberDefaults(inputData, defaultStep, precision, enable_rounding) {
|
function getNumberDefaults(inputData, defaultStep, precision, enable_rounding) {
|
||||||
let defaultVal = inputData[1]["default"];
|
let defaultVal = inputData[1]["default"];
|
||||||
@ -497,65 +498,25 @@ export const ComfyWidgets = {
|
|||||||
return { widget: uploadWidget };
|
return { widget: uploadWidget };
|
||||||
},
|
},
|
||||||
SUBFLOWUPLOAD(node, inputName, inputData, app) {
|
SUBFLOWUPLOAD(node, inputName, inputData, app) {
|
||||||
// const subflowWidget = node.widgets.find((w) => w.name === "subflow");
|
|
||||||
let uploadWidget;
|
let uploadWidget;
|
||||||
|
|
||||||
// var default_value = subflowWidget.value;
|
|
||||||
// Object.defineProperty(subflowWidget, "value", {
|
|
||||||
// set : function(value) {
|
|
||||||
// this._real_value = value;
|
|
||||||
// },
|
|
||||||
|
|
||||||
// get : function() {
|
|
||||||
// let value = "";
|
|
||||||
// if (this._real_value) {
|
|
||||||
// value = this._real_value;
|
|
||||||
// } else {
|
|
||||||
// return default_value;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (value.filename) {
|
|
||||||
// let real_value = value;
|
|
||||||
// value = "";
|
|
||||||
// if (real_value.subfolder) {
|
|
||||||
// value = real_value.subfolder + "/";
|
|
||||||
// }
|
|
||||||
|
|
||||||
// value += real_value.filename;
|
|
||||||
|
|
||||||
// if(real_value.type && real_value.type !== "input")
|
|
||||||
// value += ` [${real_value.type}]`;
|
|
||||||
// }
|
|
||||||
// return value;
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
// Add our own callback to the combo widget to render an image when it changes
|
|
||||||
// const cb = node.callback;
|
|
||||||
// imageWidget.callback = function () {
|
|
||||||
// if (cb) {
|
|
||||||
// return cb.apply(this, arguments);
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
// On load if we have a value then render the image
|
|
||||||
// The value isnt set immediately so we need to wait a moment
|
|
||||||
// No change callbacks seem to be fired on initial setting of the value
|
|
||||||
// requestAnimationFrame(() => {
|
|
||||||
|
|
||||||
// });
|
|
||||||
|
|
||||||
const uploadFile = async (file) => {
|
const uploadFile = async (file) => {
|
||||||
const reader = new FileReader();
|
if (file.type === "image/png") {
|
||||||
const filename = file.name;
|
const pngInfo = await getPngMetadata(file);
|
||||||
reader.onload = (e) => {
|
if (pngInfo?.workflow) {
|
||||||
const subflow = JSON.parse(e.target.result);
|
const subflow = JSON.parse(pngInfo.workflow);
|
||||||
node.refreshNode(subflow, filename);
|
node.refreshNode(subflow, file.name);
|
||||||
};
|
}
|
||||||
reader.readAsText(file);
|
} else if (file.type === "application/json" || file.name?.endsWith(".json")) {
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.onload = () => {
|
||||||
|
const subflow = JSON.parse(reader.result);
|
||||||
|
node.refreshNode(subflow, file.name);
|
||||||
|
};
|
||||||
|
reader.readAsText(file);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const fileInput = document.createElement("input");
|
const fileInput = document.createElement("input");
|
||||||
Object.assign(fileInput, {
|
Object.assign(fileInput, {
|
||||||
type: "file",
|
type: "file",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user