mirror of
https://github.com/ciromattia/kcc
synced 2025-12-24 07:01:51 +00:00
Image has already-set profile, so use the inited one
This commit is contained in:
@@ -254,7 +254,7 @@ def applyImgOptimization(img, isSplit=False, toRight=False):
|
|||||||
img.cropWhiteSpace(10.0)
|
img.cropWhiteSpace(10.0)
|
||||||
if options.cutpagenumbers:
|
if options.cutpagenumbers:
|
||||||
img.cutPageNumber()
|
img.cutPageNumber()
|
||||||
img.resizeImage(options.upscale, options.stretch, options.black_borders, isSplit, toRight, options.profile)
|
img.resizeImage(options.upscale, options.stretch, options.black_borders, isSplit, toRight)
|
||||||
img.quantizeImage()
|
img.quantizeImage()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ class ProfileData:
|
|||||||
class ComicPage:
|
class ComicPage:
|
||||||
def __init__(self, source, device):
|
def __init__(self, source, device):
|
||||||
try:
|
try:
|
||||||
|
self.profile = device
|
||||||
self.profile_label, self.size, self.palette = ProfileData.Profiles[device]
|
self.profile_label, self.size, self.palette = ProfileData.Profiles[device]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise RuntimeError('Unexpected output device %s' % device)
|
raise RuntimeError('Unexpected output device %s' % device)
|
||||||
@@ -129,7 +130,7 @@ class ComicPage:
|
|||||||
palImg.putpalette(self.palette)
|
palImg.putpalette(self.palette)
|
||||||
self.image = self.image.quantize(palette=palImg)
|
self.image = self.image.quantize(palette=palImg)
|
||||||
|
|
||||||
def resizeImage(self, upscale=False, stretch=False, black_borders=False, isSplit=False, toRight=False, profile="KHD"):
|
def resizeImage(self, upscale=False, stretch=False, black_borders=False, isSplit=False, toRight=False):
|
||||||
method = Image.ANTIALIAS
|
method = Image.ANTIALIAS
|
||||||
if black_borders:
|
if black_borders:
|
||||||
fill = 'black'
|
fill = 'black'
|
||||||
@@ -137,7 +138,7 @@ class ComicPage:
|
|||||||
fill = 'white'
|
fill = 'white'
|
||||||
if self.image.size[0] <= self.size[0] and self.image.size[1] <= self.size[1]:
|
if self.image.size[0] <= self.size[0] and self.image.size[1] <= self.size[1]:
|
||||||
if not upscale:
|
if not upscale:
|
||||||
if isSplit and (profile == 'K4' or profile == 'KHD'):
|
if isSplit and (self.profile == 'K4' or self.profile == 'KHD'):
|
||||||
borderw = (self.size[0] - self.image.size[0])
|
borderw = (self.size[0] - self.image.size[0])
|
||||||
borderh = (self.size[1] - self.image.size[1]) / 2
|
borderh = (self.size[1] - self.image.size[1]) / 2
|
||||||
self.image = ImageOps.expand(self.image, border=(0, borderh), fill=fill)
|
self.image = ImageOps.expand(self.image, border=(0, borderh), fill=fill)
|
||||||
@@ -162,7 +163,7 @@ class ComicPage:
|
|||||||
ratioDev = float(self.size[0]) / float(self.size[1])
|
ratioDev = float(self.size[0]) / float(self.size[1])
|
||||||
if (float(self.image.size[0]) / float(self.image.size[1])) < ratioDev:
|
if (float(self.image.size[0]) / float(self.image.size[1])) < ratioDev:
|
||||||
diff = int(self.image.size[1] * ratioDev) - self.image.size[0]
|
diff = int(self.image.size[1] * ratioDev) - self.image.size[0]
|
||||||
if isSplit and (profile == 'K4' or profile == 'KHD'):
|
if isSplit and (self.profile == 'K4' or self.profile == 'KHD'):
|
||||||
diff = 2
|
diff = 2
|
||||||
self.image = ImageOps.expand(self.image, border=(diff / 2, 0), fill=fill)
|
self.image = ImageOps.expand(self.image, border=(diff / 2, 0), fill=fill)
|
||||||
elif (float(self.image.size[0]) / float(self.image.size[1])) > ratioDev:
|
elif (float(self.image.size[0]) / float(self.image.size[1])) > ratioDev:
|
||||||
|
|||||||
Reference in New Issue
Block a user