Orthographic

This commit is contained in:
Ciro Mattia Gonano committed 2013-06-19 10:04:58 +02:00
1 parent fd493dba9a
commit c09e050084
1 file changed
+7 -7
+7 -7
View File
@@ -123,21 +123,21 @@ class ComicPage:
raise RuntimeError('Cannot read image file %s' % source) raise RuntimeError('Cannot read image file %s' % source)
self.image = self.image.convert('RGB') self.image = self.image.convert('RGB')
def saveToDir(self, targetdir, forcepng, color, sufix=None): def saveToDir(self, targetdir, forcepng, color, suffix=None):
filename = os.path.basename(self.origFileName) filename = os.path.basename(self.origFileName)
try: try:
if not color: if not color:
self.image = self.image.convert('L') # convert to grayscale self.image = self.image.convert('L') # convert to grayscale
# Sufix is used to recognise which files need horizontal Panel View. # Suffix is used to recognise which files need horizontal Panel View.
if sufix == "R": if suffix == "R":
sufix = "_rotated" suffix = "_rotated"
else: else:
sufix = "" suffix = ""
os.remove(os.path.join(targetdir, filename)) os.remove(os.path.join(targetdir, filename))
if forcepng: if forcepng:
self.image.save(os.path.join(targetdir, os.path.splitext(filename)[0] + sufix + ".png"), "PNG") self.image.save(os.path.join(targetdir, os.path.splitext(filename)[0] + suffix + ".png"), "PNG")
else: else:
self.image.save(os.path.join(targetdir, os.path.splitext(filename)[0] + sufix + ".jpg"), "JPEG") self.image.save(os.path.join(targetdir, os.path.splitext(filename)[0] + suffix + ".jpg"), "JPEG")
except IOError as e: except IOError as e:
raise RuntimeError('Cannot write image in directory %s: %s' % (targetdir, e)) raise RuntimeError('Cannot write image in directory %s: %s' % (targetdir, e))