feat(SaveImageLM): expose webp_method and jpeg_subsampling as conditional node inputs

Add two new optional parameters to the Save Image node:

- webp_method (INT, 0-6, default 6): Controls WebP compression level.
  0=fastest/largest, 6=slowest/smallest. Previously hardcoded to 0.
- jpeg_subsampling (INT, 0-2, default 0): Controls JPEG chroma
  subsampling. 0=4:4:4 (best quality), 1=4:2:2, 2=4:2:0.

Frontend JS extension hides/disables each parameter when the
selected file_format doesn't apply (e.g., webp_method is hidden
when saving as PNG or JPEG). 7 new tests cover parameter plumbing
and default consistency across INPUT_TYPES, save_images(), and
process_image().
This commit is contained in:
Will Miao
2026-07-24 19:32:51 +08:00
parent e341e0b9d2
commit 55896669fc
3 changed files with 154 additions and 3 deletions

View File

@@ -130,6 +130,35 @@ app.registerExtension({
widget.serializeValue = () => {
return applyTextReplacements(widget.value);
};
// --- Conditional widget visibility for webp_method / jpeg_subsampling ---
const formatWidget = getWidgetByName(this, "file_format");
const webpMethodWidget = getWidgetByName(this, "webp_method");
const jpegSubWidget = getWidgetByName(this, "jpeg_subsampling");
function updateFormatConditional() {
const fmt = formatWidget?.value;
if (webpMethodWidget) {
webpMethodWidget.disabled = fmt !== "webp";
webpMethodWidget.hidden = fmt !== "webp";
}
if (jpegSubWidget) {
jpegSubWidget.disabled = fmt !== "jpeg";
jpegSubWidget.hidden = fmt !== "jpeg";
}
}
// Set initial state
updateFormatConditional();
// Watch for format changes
if (formatWidget) {
const origCallback = formatWidget.callback;
formatWidget.callback = function (value) {
origCallback?.call(this, value);
updateFormatConditional();
};
}
});
},
});