|
|
@ -1,4 +1,4 @@
|
|
|
|
from PIL import Image, ImageFile
|
|
|
|
from PIL import Image, ImageFile, UnidentifiedImageError
|
|
|
|
|
|
|
|
|
|
|
|
def conditioning_set_values(conditioning, values={}):
|
|
|
|
def conditioning_set_values(conditioning, values={}):
|
|
|
|
c = []
|
|
|
|
c = []
|
|
|
@ -11,14 +11,15 @@ def conditioning_set_values(conditioning, values={}):
|
|
|
|
return c
|
|
|
|
return c
|
|
|
|
|
|
|
|
|
|
|
|
def open_image(path):
|
|
|
|
def open_image(path):
|
|
|
|
try :
|
|
|
|
prev_value = None
|
|
|
|
ImageFile.LOAD_TRUNCATED_IMAGES = False
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
img = Image.open(path)
|
|
|
|
img = Image.open(path)
|
|
|
|
|
|
|
|
except (UnidentifiedImageError, ValueError): #PIL issues #4472 and #2445
|
|
|
|
except:
|
|
|
|
prev_value = ImageFile.LOAD_TRUNCATED_IMAGES
|
|
|
|
ImageFile.LOAD_TRUNCATED_IMAGES = True
|
|
|
|
ImageFile.LOAD_TRUNCATED_IMAGES = True
|
|
|
|
img = Image.open(path)
|
|
|
|
img = Image.open(path)
|
|
|
|
|
|
|
|
|
|
|
|
finally:
|
|
|
|
finally:
|
|
|
|
ImageFile.LOAD_TRUNCATED_IMAGES = False
|
|
|
|
if prev_value is not None:
|
|
|
|
|
|
|
|
ImageFile.LOAD_TRUNCATED_IMAGES = prev_value
|
|
|
|
return img
|
|
|
|
return img
|
|
|
|