Made preview_format parameterizable for extensibility.

This commit is contained in:
Dr.Lt.Data 2023-06-03 20:49:12 +09:00
parent c78e6a58c0
commit 728e5de33f
3 changed files with 9 additions and 3 deletions

View File

@ -41,7 +41,7 @@ async function uploadMask(filepath, formData) {
}); });
ComfyApp.clipspace.imgs[ComfyApp.clipspace['selectedIndex']] = new Image(); ComfyApp.clipspace.imgs[ComfyApp.clipspace['selectedIndex']] = new Image();
ComfyApp.clipspace.imgs[ComfyApp.clipspace['selectedIndex']].src = "/view?" + new URLSearchParams(filepath).toString() + "&preview=jpeg"; ComfyApp.clipspace.imgs[ComfyApp.clipspace['selectedIndex']].src = "/view?" + new URLSearchParams(filepath).toString() + "&preview="+app.preview_format;
if(ComfyApp.clipspace.images) if(ComfyApp.clipspace.images)
ComfyApp.clipspace.images[ComfyApp.clipspace['selectedIndex']] = filepath; ComfyApp.clipspace.images[ComfyApp.clipspace['selectedIndex']] = filepath;

View File

@ -49,6 +49,12 @@ export class ComfyApp {
* @type {boolean} * @type {boolean}
*/ */
this.shiftDown = false; this.shiftDown = false;
/**
* file format for preview
* @type {string}
*/
this.preview_format = "jpeg";
} }
static isImageNode(node) { static isImageNode(node) {
@ -371,7 +377,7 @@ export class ComfyApp {
const img = new Image(); const img = new Image();
img.onload = () => r(img); img.onload = () => r(img);
img.onerror = () => r(null); img.onerror = () => r(null);
img.src = "/view?" + new URLSearchParams(src).toString() + "&preview=jpeg"; img.src = "/view?" + new URLSearchParams(src).toString() + "&preview="+app.preview_format;
}); });
}) })
).then((imgs) => { ).then((imgs) => {

View File

@ -303,7 +303,7 @@ export const ComfyWidgets = {
subfolder = name.substring(0, folder_separator); subfolder = name.substring(0, folder_separator);
name = name.substring(folder_separator + 1); name = name.substring(folder_separator + 1);
} }
img.src = `/view?filename=${name}&type=input&subfolder=${subfolder}&preview=jpeg`; img.src = `/view?filename=${name}&type=input&subfolder=${subfolder}&preview=${app.preview_format}`;
node.setSizeForImage?.(); node.setSizeForImage?.();
} }