mirror of
https://github.com/ciromattia/kcc
synced 2026-10-17 15:02:32 +00:00
Fixed a serious bug on resizing when img ratio was bigger than device one
This commit is contained in:
@@ -89,6 +89,7 @@ and installed in `/usr/local/bin/`
|
|||||||
Reworked options system (call with -h option to get the inline help)
|
Reworked options system (call with -h option to get the inline help)
|
||||||
- 1.40 - Added some options for controlling image optimization
|
- 1.40 - Added some options for controlling image optimization
|
||||||
Further optimization (ImageOps, page numbering cut, autocontrast)
|
Further optimization (ImageOps, page numbering cut, autocontrast)
|
||||||
|
- 1.41 - Fixed a serious bug on resizing when img ratio was bigger than device one
|
||||||
- 2.00 - GUI! AppleScript is gone and Tk is used to provide cross-platform GUI support.
|
- 2.00 - GUI! AppleScript is gone and Tk is used to provide cross-platform GUI support.
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|||||||
+9
-1
@@ -26,6 +26,9 @@
|
|||||||
# WARNING: PIL is required for all image mangling!
|
# WARNING: PIL is required for all image mangling!
|
||||||
# 1.30 - Fixed an issue in OPF generation for device resolution
|
# 1.30 - Fixed an issue in OPF generation for device resolution
|
||||||
# Reworked options system (call with -h option to get the inline help)
|
# Reworked options system (call with -h option to get the inline help)
|
||||||
|
# 1.40 - Added some options for controlling image optimization
|
||||||
|
# Further optimization (ImageOps, page numbering cut, autocontrast)
|
||||||
|
# 1.41 - Fixed a serious bug on resizing when img ratio was bigger than device one
|
||||||
#
|
#
|
||||||
# Todo:
|
# Todo:
|
||||||
# - Add gracefully exit for CBR if no rarfile.py and no unrar
|
# - Add gracefully exit for CBR if no rarfile.py and no unrar
|
||||||
@@ -180,17 +183,21 @@ def main(argv=None):
|
|||||||
raise
|
raise
|
||||||
filelist = []
|
filelist = []
|
||||||
if options.imgproc:
|
if options.imgproc:
|
||||||
|
print "Processing images..."
|
||||||
try:
|
try:
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
print "Splitting double pages..."
|
print "Splitting double pages..."
|
||||||
for file in os.listdir(dir):
|
for file in os.listdir(dir):
|
||||||
if getImageFileName(file) is not None:
|
if getImageFileName(file) is not None:
|
||||||
|
print ".",
|
||||||
img = image.ComicPage(dir+'/'+file, options.profile)
|
img = image.ComicPage(dir+'/'+file, options.profile)
|
||||||
img.splitPage(dir, options.righttoleft)
|
img.splitPage(dir, options.righttoleft)
|
||||||
for file in os.listdir(dir):
|
for file in os.listdir(dir):
|
||||||
if getImageFileName(file) is not None:
|
if getImageFileName(file) is not None:
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
print "Optimizing " + file + " for " + options.profile
|
print "Optimizing " + file + " for " + options.profile
|
||||||
|
else:
|
||||||
|
print ".",
|
||||||
img = image.ComicPage(dir+'/'+file, options.profile)
|
img = image.ComicPage(dir+'/'+file, options.profile)
|
||||||
img.optimizeImage()
|
img.optimizeImage()
|
||||||
img.cropWhiteSpace(10.0)
|
img.cropWhiteSpace(10.0)
|
||||||
@@ -202,6 +209,7 @@ def main(argv=None):
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
print "Could not load PIL, not optimizing image"
|
print "Could not load PIL, not optimizing image"
|
||||||
|
|
||||||
|
print "Creating ePub structure..."
|
||||||
for file in os.listdir(dir):
|
for file in os.listdir(dir):
|
||||||
if getImageFileName(file) is not None and isInFilelist(file,filelist) == False:
|
if getImageFileName(file) is not None and isInFilelist(file,filelist) == False:
|
||||||
# put credits at the end
|
# put credits at the end
|
||||||
@@ -215,7 +223,7 @@ def main(argv=None):
|
|||||||
options.title = os.path.basename(dir)
|
options.title = os.path.basename(dir)
|
||||||
NCXbuilder(dir,options.title)
|
NCXbuilder(dir,options.title)
|
||||||
# ensure we're sorting files alphabetically
|
# ensure we're sorting files alphabetically
|
||||||
filelist = sorted(filelist, key=lambda name: name[0])
|
filelist = sorted(filelist, key=lambda name: name[0].lower())
|
||||||
OPFBuilder(options.profile,dir,options.title,filelist)
|
OPFBuilder(options.profile,dir,options.title,filelist)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -96,7 +96,7 @@ class ComicPage:
|
|||||||
|
|
||||||
def saveToDir(self,targetdir):
|
def saveToDir(self,targetdir):
|
||||||
filename = os.path.basename(self.origFileName)
|
filename = os.path.basename(self.origFileName)
|
||||||
print "Saving to " + targetdir + '/' + filename
|
#print "Saving to " + targetdir + '/' + filename
|
||||||
try:
|
try:
|
||||||
self.image = self.image.convert('L') # convert to grayscale
|
self.image = self.image.convert('L') # convert to grayscale
|
||||||
self.image.save(targetdir + '/' + filename,"JPEG")
|
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]))
|
newImage.paste(self.image, (diff / 2, 0, diff / 2 + self.image.size[0], self.image.size[1]))
|
||||||
self.image = newImage
|
self.image = newImage
|
||||||
elif (float(self.image.size[0]) / float(self.image.size[1])) > ratioDev:
|
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 = 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]))
|
newImage.paste(self.image, (0, diff / 2, self.image.size[0], diff / 2 + self.image.size[1]))
|
||||||
self.image = newImage
|
self.image = newImage
|
||||||
@@ -143,7 +143,7 @@ class ComicPage:
|
|||||||
def splitPage(self, targetdir, righttoleft=False):
|
def splitPage(self, targetdir, righttoleft=False):
|
||||||
width, height = self.image.size
|
width, height = self.image.size
|
||||||
dstwidth, dstheight = self.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
|
# only split if origin is not oriented the same as target
|
||||||
if (width > height) != (dstwidth > dstheight):
|
if (width > height) != (dstwidth > dstheight):
|
||||||
if width > height:
|
if width > height:
|
||||||
|
|||||||
Reference in New Issue
Block a user