From d86f158b9f5cd4185b1e83846282ce9f74b06807 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 2 Sep 2010 23:19:15 -0400 Subject: [PATCH] re-render a chunk if the image is corrupt --- chunk.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/chunk.py b/chunk.py index ffce3d7..3e8492b 100644 --- a/chunk.py +++ b/chunk.py @@ -103,7 +103,16 @@ class ChunkRenderer(object): dest_path = os.path.join(destdir, dest_filename) if os.path.exists(dest_path): - return dest_path + # Try to open it to see if it's corrupt or something (can happen if + # the program crashed last time) + try: + testimg = Image.open(dest_path) + testimg.load() + except Exception: + # guess not, continue below + pass + else: + return dest_path else: # Remove old images for this chunk for oldimg in os.listdir(destdir):