1
0
mirror of https://github.com/ciromattia/kcc synced 2026-06-01 12:13:12 +00:00

Merge branch 'new-gui' of github.com:ciromattia/kcc into new-gui

This commit is contained in:
Ciro Mattia Gonano
2013-06-20 12:51:47 +02:00
parent 941a4fa14f
commit 224d2b89b1
+7 -7
View File
@@ -130,23 +130,23 @@ class ComicPage:
self.image = Image.open(source) self.image = Image.open(source)
self.image = self.image.convert('RGB') self.image = self.image.convert('RGB')
def saveToDir(self, targetdir, forcepng, color, wipe, sufix=None): def saveToDir(self, targetdir, forcepng, color, wipe, 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
if sufix == "R": if suffix == "R":
sufix = "_kccrotated" suffix = "_kccrotated"
else: else:
sufix = "" suffix = ""
if wipe: if wipe:
os.remove(os.path.join(targetdir, filename)) os.remove(os.path.join(targetdir, filename))
else: else:
sufix += "_kcchq" suffix += "_kcchq"
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))