1
0
mirror of https://github.com/ciromattia/kcc synced 2026-07-05 04:25:31 +00:00

Force JPEG output

This commit is contained in:
Paweł Jastrzębski
2013-03-20 16:20:17 +01:00
parent 23336de5b5
commit cff9b73b80
2 changed files with 10 additions and 10 deletions
+4 -4
View File
@@ -113,15 +113,15 @@ class ComicPage:
raise RuntimeError('Cannot read image file %s' % source)
self.image = self.image.convert('RGB')
def saveToDir(self, targetdir, notquantize):
def saveToDir(self, targetdir, forcepng):
filename = os.path.basename(self.origFileName)
try:
self.image = self.image.convert('L') # convert to grayscale
os.remove(os.path.join(targetdir, filename))
if notquantize:
self.image.save(os.path.join(targetdir, os.path.splitext(filename)[0] + ".jpg"), "JPEG")
else:
if forcepng:
self.image.save(os.path.join(targetdir, os.path.splitext(filename)[0] + ".png"), "PNG")
else:
self.image.save(os.path.join(targetdir, os.path.splitext(filename)[0] + ".jpg"), "JPEG", quality=95)
except IOError as e:
raise RuntimeError('Cannot write image in directory %s: %s' % (targetdir, e))