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
72508a8d
Commit
72508a8d
authored
May 04, 2024
by
comfyanonymous
Browse files
Only set LOAD_TRUNCATED_IMAGES when if the Image open fails.
Document which PIL issues this works around.
parent
0d45efb7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
node_helpers.py
node_helpers.py
+8
-7
No files found.
node_helpers.py
View file @
72508a8d
from
PIL
import
Image
,
ImageFile
from
PIL
import
Image
,
ImageFile
,
UnidentifiedImageError
def
conditioning_set_values
(
conditioning
,
values
=
{}):
c
=
[]
...
...
@@ -11,14 +11,15 @@ def conditioning_set_values(conditioning, values={}):
return
c
def
open_image
(
path
):
try
:
ImageFile
.
LOAD_TRUNCATED_IMAGES
=
False
prev_value
=
None
try
:
img
=
Image
.
open
(
path
)
except
:
except
(
UnidentifiedImageError
,
ValueError
):
#PIL issues #4472 and #2445
prev_value
=
ImageFile
.
LOAD_TRUNCATED_IMAGES
ImageFile
.
LOAD_TRUNCATED_IMAGES
=
True
img
=
Image
.
open
(
path
)
finally
:
ImageFile
.
LOAD_TRUNCATED_IMAGES
=
False
if
prev_value
is
not
None
:
ImageFile
.
LOAD_TRUNCATED_IMAGES
=
prev_value
return
img
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