Skip to content

Commit 577f325

Browse files
author
mercuryZ
authored
fix non-picture file error
1 parent 13e0b64 commit 577f325

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Windows_Wallpaper_Script/wallpaper_extract.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ def extract_wall():
6666
for filename in os.listdir(w.file_urls["wall_dst"]):
6767
base_file, ext = os.path.splitext(filename)
6868
if ext == ".jpg":
69-
im = Image.open(w.file_urls["wall_dst"] + filename)
69+
try:
70+
im = Image.open(w.file_urls["wall_dst"] + filename)
71+
except IOError:
72+
print("This isn't a picture.", filename)
7073
if list(im.size)[0] != 1920 and list(im.size)[0] != 1080:
7174
im.close()
7275
os.remove(w.file_urls["wall_dst"] + filename)

0 commit comments

Comments
 (0)