make preloader throw if file is corrupt

This commit is contained in:
Victor Hall 2023-01-17 16:34:00 -05:00
parent 2b447f3f0c
commit 4eac671544
1 changed files with 8 additions and 1 deletions

View File

@ -69,7 +69,14 @@ class DataLoaderMultiAspect():
#if debug_level > 1: print(f" * DLMA file: {pathname} with caption: {caption}") #if debug_level > 1: print(f" * DLMA file: {pathname} with caption: {caption}")
image = Image.open(pathname) try:
image = Image.open(pathname).convert('RGB')
except Exception as e:
print(f"File corrupt. Cannot continue. Error opening image: {self.pathname}")
print(e)
print(f"You should remove this image or try to correct it by resaving it.")
exit()
width, height = image.size width, height = image.size
image_aspect = width / height image_aspect = width / height