mirror of
https://github.com/ciromattia/kcc
synced 2026-07-04 20:15:39 +00:00
Added ultra quality mode
This commit is contained in:
+17
-10
@@ -130,17 +130,23 @@ class ComicPage:
|
||||
self.image = Image.open(source)
|
||||
self.image = self.image.convert('RGB')
|
||||
|
||||
def saveToDir(self, targetdir, forcepng, color, sufix=None):
|
||||
def saveToDir(self, targetdir, forcepng, color, wipe, sufix=None):
|
||||
filename = os.path.basename(self.origFileName)
|
||||
try:
|
||||
if not color:
|
||||
self.image = self.image.convert('L') # convert to grayscale
|
||||
# Sufix is used to recognise which files need horizontal Panel View.
|
||||
if sufix == "R":
|
||||
sufix = "_rotated"
|
||||
sufix = "_kccrotated"
|
||||
#elif sufix == "NoneLQ":
|
||||
#sufix = ""
|
||||
elif sufix == "RLQ":
|
||||
sufix = "_kccrotated"
|
||||
else:
|
||||
sufix = ""
|
||||
os.remove(os.path.join(targetdir, filename))
|
||||
if wipe:
|
||||
os.remove(os.path.join(targetdir, filename))
|
||||
else:
|
||||
sufix += "_kcchq"
|
||||
if forcepng:
|
||||
self.image.save(os.path.join(targetdir, os.path.splitext(filename)[0] + sufix + ".png"), "PNG")
|
||||
else:
|
||||
@@ -167,13 +173,13 @@ class ComicPage:
|
||||
self.image = self.image.quantize(palette=palImg)
|
||||
|
||||
def resizeImage(self, upscale=False, stretch=False, black_borders=False, isSplit=False, toRight=False,
|
||||
landscapeMode=False, noPanelViewHQ=False):
|
||||
landscapeMode=False, qualityMode=0):
|
||||
method = Image.ANTIALIAS
|
||||
if black_borders:
|
||||
fill = 'black'
|
||||
else:
|
||||
fill = 'white'
|
||||
if noPanelViewHQ:
|
||||
if qualityMode == 0:
|
||||
size = (self.size[0], self.size[1])
|
||||
else:
|
||||
size = (self.panelviewsize[0], self.panelviewsize[1])
|
||||
@@ -210,7 +216,7 @@ class ComicPage:
|
||||
self.image = ImageOps.fit(self.image, size, method=method, centering=(0.5, 0.5))
|
||||
return self.image
|
||||
|
||||
def splitPage(self, targetdir, righttoleft=False, rotate=False):
|
||||
def splitPage(self, targetdir, righttoleft=False, rotate=False, wipe=False):
|
||||
width, height = self.image.size
|
||||
dstwidth, dstheight = self.size
|
||||
#print "Image is %d x %d" % (width,height)
|
||||
@@ -229,8 +235,8 @@ class ComicPage:
|
||||
leftbox = (0, 0, width, height / 2)
|
||||
rightbox = (0, height / 2, width, height)
|
||||
filename = os.path.splitext(os.path.basename(self.origFileName))
|
||||
fileone = targetdir + '/' + filename[0] + '-kcca' + filename[1]
|
||||
filetwo = targetdir + '/' + filename[0] + '-kccb' + filename[1]
|
||||
fileone = targetdir + '/' + filename[0] + '_kcca' + filename[1]
|
||||
filetwo = targetdir + '/' + filename[0] + '_kccb' + filename[1]
|
||||
try:
|
||||
if righttoleft:
|
||||
pageone = self.image.crop(rightbox)
|
||||
@@ -240,7 +246,8 @@ class ComicPage:
|
||||
pagetwo = self.image.crop(rightbox)
|
||||
pageone.save(fileone)
|
||||
pagetwo.save(filetwo)
|
||||
os.remove(self.origFileName)
|
||||
if wipe:
|
||||
os.remove(self.origFileName)
|
||||
except IOError as e:
|
||||
raise RuntimeError('Cannot write image in directory %s: %s' % (targetdir, e))
|
||||
return fileone, filetwo
|
||||
|
||||
Reference in New Issue
Block a user