Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
2ec980bb
Commit
2ec980bb
authored
Jun 05, 2023
by
comfyanonymous
Browse files
Limit preview to webp and RGB jpeg.
parent
9f3a19b7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
10 deletions
+8
-10
server.py
server.py
+6
-7
web/scripts/ui.js
web/scripts/ui.js
+2
-3
No files found.
server.py
View file @
2ec980bb
...
...
@@ -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
]
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
}
'
,
...
...
web/scripts/ui.js
View file @
2ec980bb
...
...
@@ -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}
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment