1
0
mirror of https://github.com/ciromattia/kcc synced 2026-07-05 12:35:35 +00:00

"Crash like professional" - Improved error handling

This commit is contained in:
Paweł Jastrzębski
2013-06-18 15:52:21 +02:00
parent 8a9f11b0f5
commit 4b4424ae92
3 changed files with 22 additions and 5 deletions
+7
View File
@@ -116,11 +116,18 @@ class ComicPage:
self.profile_label, self.size, self.palette, self.gamma, self.panelviewsize = device
except KeyError:
raise RuntimeError('Unexpected output device %s' % device)
# Detect corrupted files - Phase 2
try:
self.origFileName = source
self.image = Image.open(source)
except IOError:
raise RuntimeError('Cannot read image file %s' % source)
# Detect corrupted files - Phase 3
try:
self.image.verify()
except:
raise RuntimeError('Image file %s is corrupted' % source)
self.image = Image.open(source)
self.image = self.image.convert('RGB')
def saveToDir(self, targetdir, forcepng, color, sufix=None):