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
edcff9ab
Commit
edcff9ab
authored
Aug 29, 2023
by
Chris
Browse files
copy metadata into modified image
parent
65cae62c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletion
+5
-1
server.py
server.py
+5
-1
No files found.
server.py
View file @
edcff9ab
...
...
@@ -12,6 +12,7 @@ import json
import
glob
import
struct
from
PIL
import
Image
,
ImageOps
from
PIL.PngImagePlugin
import
PngInfo
from
io
import
BytesIO
try
:
...
...
@@ -233,13 +234,16 @@ class PromptServer():
if
os
.
path
.
isfile
(
file
):
with
Image
.
open
(
file
)
as
original_pil
:
metadata
=
PngInfo
()
for
key
in
original_pil
.
text
:
metadata
.
add_text
(
key
,
original_pil
.
text
[
key
])
original_pil
=
original_pil
.
convert
(
'RGBA'
)
mask_pil
=
Image
.
open
(
image
.
file
).
convert
(
'RGBA'
)
# alpha copy
new_alpha
=
mask_pil
.
getchannel
(
'A'
)
original_pil
.
putalpha
(
new_alpha
)
original_pil
.
save
(
filepath
,
compress_level
=
4
)
original_pil
.
save
(
filepath
,
compress_level
=
4
,
pnginfo
=
metadata
)
return
image_upload
(
post
,
image_save_function
)
...
...
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