1
0
mirror of https://github.com/ciromattia/kcc synced 2026-07-30 00:23:18 +00:00

Fixed a serious bug on resizing when img ratio was bigger than device one

This commit is contained in:
Ciro Mattia Gonano
2013-01-18 11:54:34 +01:00
parent f231e9112a
commit 9ee851d04b
3 changed files with 13 additions and 4 deletions
+3 -3
View File
@@ -96,7 +96,7 @@ class ComicPage:
def saveToDir(self,targetdir):
filename = os.path.basename(self.origFileName)
print "Saving to " + targetdir + '/' + filename
#print "Saving to " + targetdir + '/' + filename
try:
self.image = self.image.convert('L') # convert to grayscale
self.image.save(targetdir + '/' + filename,"JPEG")
@@ -133,7 +133,7 @@ class ComicPage:
newImage.paste(self.image, (diff / 2, 0, diff / 2 + self.image.size[0], self.image.size[1]))
self.image = newImage
elif (float(self.image.size[0]) / float(self.image.size[1])) > ratioDev:
diff = int(self.image.size[0] * ratioDev) - self.image.size[1]
diff = int(self.image.size[0] / ratioDev) - self.image.size[1]
newImage = Image.new('RGB', (self.image.size[0], self.image.size[1] + diff), (255,255,255))
newImage.paste(self.image, (0, diff / 2, self.image.size[0], diff / 2 + self.image.size[1]))
self.image = newImage
@@ -143,7 +143,7 @@ class ComicPage:
def splitPage(self, targetdir, righttoleft=False):
width, height = self.image.size
dstwidth, dstheight = self.size
print "Image is %d x %d" % (width,height)
#print "Image is %d x %d" % (width,height)
# only split if origin is not oriented the same as target
if (width > height) != (dstwidth > dstheight):
if width > height: