change live preview format to jpeg to prevent unreasonably slow previews for large images, and add an option to let user select the format

This commit is contained in:
AUTOMATIC
2023-05-11 08:14:45 +03:00
parent e334758ec2
commit b7e160a87d
2 changed files with 3 additions and 2 deletions

View File

@@ -95,9 +95,9 @@ def progressapi(req: ProgressRequest):
image = shared.state.current_image
if image is not None:
buffered = io.BytesIO()
image.save(buffered, format="png")
image.save(buffered, format=opts.live_previews_format)
base64_image = base64.b64encode(buffered.getvalue()).decode('ascii')
live_preview = f"data:image/png;base64,{base64_image}"
live_preview = f"data:image/{opts.live_previews_format};base64,{base64_image}"
id_live_preview = shared.state.id_live_preview
else:
live_preview = None