diff --git a/server.py b/server.py index b0dd3382..c0b4729d 100644 --- a/server.py +++ b/server.py @@ -221,19 +221,18 @@ class PromptServer(): with Image.open(file) as img: preview_info = request.rel_url.query['preview'].split(';') - if preview_info[0] == "L" or preview_info[0] == "l": - img = img.convert("L") - image_format = preview_info[1] - else: - img = img.convert("RGB") # jpeg doesn't support RGBA - image_format = preview_info[0] + image_format = preview_info[0] + if image_format not in ['webp', 'jpeg']: + image_format = 'webp' quality = 90 if preview_info[-1].isdigit(): quality = int(preview_info[-1]) buffer = BytesIO() - img.save(buffer, format=image_format, optimize=True, quality=quality) + if image_format in ['jpeg']: + img = img.convert("RGB") + img.save(buffer, format=image_format, quality=quality) buffer.seek(0) return web.Response(body=buffer.read(), content_type=f'image/{image_format}', diff --git a/web/scripts/ui.js b/web/scripts/ui.js index 6b764d43..a26eedec 100644 --- a/web/scripts/ui.js +++ b/web/scripts/ui.js @@ -465,12 +465,11 @@ export class ComfyUI { /** * file format for preview * - * L?;format;quality + * format;quality * * ex) - * L;webp;50 -> grayscale, webp, quality 50 + * webp;50 -> webp, quality 50 * jpeg;80 -> rgb, jpeg, quality 80 - * png -> rgb, png, default quality(=90) * * @type {string} */