按 OpenAI 官方放开 GIF+参考图,SVG 仍仅文生图;有蒙版禁用 GIF/SVG

This commit is contained in:
Jony
2026-11-09 11:41:31 +08:00
parent 81a0e50b2d
commit 7d6e7fa5d8
12 changed files with 190 additions and 31 deletions
+18 -5
View File
@@ -27,8 +27,18 @@ function setWidgetHidden(widget, hidden) {
} else delete widget.computeSize;
}
function hasReferenceOrMask(node) {
function hasMask(node) {
if (findWidget(node, "遮罩")?.value) return true;
// Connected inputs on modern nodes are not always mirrored into widget values.
const inputs = node.inputs || [];
for (const input of inputs) {
if (!input || input.link == null) continue;
if (input.name === "遮罩") return true;
}
return false;
}
function hasReference(node) {
const widgets = node.widgets || [];
for (const widget of widgets) {
if (/^参考图/.test(widget.name) && widget.value) return true;
@@ -37,7 +47,7 @@ function hasReferenceOrMask(node) {
const inputs = node.inputs || [];
for (const input of inputs) {
if (!input || input.link == null) continue;
if (input.name === "遮罩" || /^参考图/.test(input.name) || input.name === "参考图组") {
if (/^参考图/.test(input.name) || input.name === "参考图组") {
return true;
}
}
@@ -77,12 +87,15 @@ function updateQualityOptions(node) {
const formatWidget = findWidget(node, "输出格式") || findWidget(node, "图片输出格式");
const isBatch = (node.comfyClass || node.type) === "O1keyGPTImageBatch";
if (formatWidget) {
const blocked = hasReferenceOrMask(node);
let values = isBatch
? (is26 ? BATCH_26 : BATCH_RASTER)
: (is26 ? FORMAT_26 : RASTER_FORMATS);
if (is26 && blocked) {
values = values.filter((value) => !/^(svg|gif|SVG|GIF)$/i.test(value));
if (is26) {
if (hasMask(node)) {
values = values.filter((value) => !/^(svg|gif|SVG|GIF)$/i.test(value));
} else if (hasReference(node)) {
values = values.filter((value) => !/^(svg|SVG)$/i.test(value));
}
}
formatWidget.options ??= {};
formatWidget.options.values = [...values];
+14 -5
View File
@@ -119,7 +119,7 @@ const GPT_OUTPUT_FORMATS = [
];
const GPT_26_EXTRA_OUTPUT_FORMATS = [
{ value: "svg", label: "SVG", description: "矢量,仅纯文生图" },
{ value: "gif", label: "GIF", description: "动图,仅纯文生图" },
{ value: "gif", label: "GIF", description: "动图,可带参考图引导动画" },
];
const SEEDREAM_RESOLUTIONS = ["智能", "1K", "2K"];
const SEEDREAM_LAYER_RESOLUTIONS = ["智能", "1K", "1.5K", "2K"];
@@ -1537,11 +1537,20 @@ function syncGptOutputOptions(node) {
formats = SEEDREAM_OUTPUT_FORMATS;
} else {
const is26 = /^gpt-image-2\.6-/.test(String(model || ""));
const hasRefs = (node._o1igReferences || []).length > 0
|| (node._o1igModelReferences || []).length > 0
|| Boolean(node._o1igMask);
const hasImages = (node._o1igReferences || []).length > 0
|| (node._o1igModelReferences || []).length > 0;
const hasMask = Boolean(node._o1igMask);
formats = [...GPT_OUTPUT_FORMATS];
if (is26 && !hasRefs) formats = [...formats, ...GPT_26_EXTRA_OUTPUT_FORMATS];
if (is26) {
if (!hasImages && !hasMask) {
formats = [...formats, ...GPT_26_EXTRA_OUTPUT_FORMATS];
} else if (hasImages && !hasMask) {
formats = [
...formats,
...GPT_26_EXTRA_OUTPUT_FORMATS.filter((option) => option.value === "gif"),
];
}
}
if (node._o1igBackground.value === "transparent") {
formats = formats.filter((option) => option.value !== "jpeg" && option.value !== "svg" && option.value !== "gif");
}