about summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xkcc-c2e.py6
-rwxr-xr-xkcc-c2p.py6
-rwxr-xr-xkcc.py6
-rwxr-xr-xkcc/comic2ebook.py2
-rw-r--r--kcc/comic2panel.py6
-rwxr-xr-xkcc/image.py32
-rw-r--r--kcc/shared.py14
7 files changed, 33 insertions, 39 deletions
diff --git a/kcc-c2e.py b/kcc-c2e.py
index 01ab86e..bbc22b2 100755
--- a/kcc-c2e.py
+++ b/kcc-c2e.py
@@ -40,10 +40,10 @@ except ImportError:
 try:
     # noinspection PyUnresolvedReferences
     import PIL
-    if tuple(map(int, ('2.5.0'.split(".")))) > tuple(map(int, (PIL.PILLOW_VERSION.split(".")))):
-        missing.append('Pillow 2.5.0+')
+    if tuple(map(int, ('2.7.0'.split(".")))) > tuple(map(int, (PIL.PILLOW_VERSION.split(".")))):
+        missing.append('Pillow 2.7.0+')
 except ImportError:
-    missing.append('Pillow 2.5.0+')
+    missing.append('Pillow 2.7.0+')
 try:
     # noinspection PyUnresolvedReferences
     import slugify
diff --git a/kcc-c2p.py b/kcc-c2p.py
index 57acd33..7388f7f 100755
--- a/kcc-c2p.py
+++ b/kcc-c2p.py
@@ -33,10 +33,10 @@ missing = []
 try:
     # noinspection PyUnresolvedReferences
     import PIL
-    if tuple(map(int, ('2.5.0'.split(".")))) > tuple(map(int, (PIL.PILLOW_VERSION.split(".")))):
-        missing.append('Pillow 2.5.0+')
+    if tuple(map(int, ('2.7.0'.split(".")))) > tuple(map(int, (PIL.PILLOW_VERSION.split(".")))):
+        missing.append('Pillow 2.7.0+')
 except ImportError:
-    missing.append('Pillow 2.5.0+')
+    missing.append('Pillow 2.7.0+')
 if len(missing) > 0:
     try:
         # noinspection PyUnresolvedReferences
diff --git a/kcc.py b/kcc.py
index 0c963d3..f7fc51f 100755
--- a/kcc.py
+++ b/kcc.py
@@ -68,10 +68,10 @@ except ImportError:
 try:
     # noinspection PyUnresolvedReferences
     import PIL
-    if tuple(map(int, ('2.5.0'.split(".")))) > tuple(map(int, (PIL.PILLOW_VERSION.split(".")))):
-        missing.append('Pillow 2.5.0+')
+    if tuple(map(int, ('2.7.0'.split(".")))) > tuple(map(int, (PIL.PILLOW_VERSION.split(".")))):
+        missing.append('Pillow 2.7.0+')
 except ImportError:
-    missing.append('Pillow 2.5.0+')
+    missing.append('Pillow 2.7.0+')
 try:
     # noinspection PyUnresolvedReferences
     import slugify
diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py
index b658c2b..7401e45 100755
--- a/kcc/comic2ebook.py
+++ b/kcc/comic2ebook.py
@@ -552,7 +552,7 @@ def imgFileProcessing(work):
             if opt.quality == 2:
                 img2 = image.ComicPage(os.path.join(dirpath, afile), opt.profileData, img.fill)
                 if img.rotated:
-                    img2.image = img2.image.rotate(90)
+                    img2.image = img2.image.rotate(90, Image.BICUBIC, True)
                     img2.rotated = True
                 imgOptimization(img2, opt, img)
                 output.append(img2.saveToDir(dirpath, opt.forcepng, opt.forcecolor))
diff --git a/kcc/comic2panel.py b/kcc/comic2panel.py
index fff58ec..3b42258 100644
--- a/kcc/comic2panel.py
+++ b/kcc/comic2panel.py
@@ -77,7 +77,7 @@ def mergeDirectory(work):
                 y += img.size[1]
                 os.remove(i)
             savePath = os.path.split(imagesClear[0])
-            result.save(os.path.join(savePath[0], os.path.splitext(savePath[1])[0] + '.png'), 'PNG')
+            result.save(os.path.join(savePath[0], os.path.splitext(savePath[1])[0] + '.png'), 'PNG', optimize=1)
     except Exception:
         return str(sys.exc_info()[1])
 
@@ -165,7 +165,7 @@ def splitImage(work):
                         panels.append(panel)
             if opt.debug:
                 # noinspection PyUnboundLocalVariable
-                debugImage.save(os.path.join(path, fileExpanded[0] + '-debug.png'), 'PNG')
+                debugImage.save(os.path.join(path, fileExpanded[0] + '-debug.png'), 'PNG', optimize=1)
 
             # Create virtual pages
             pages = []
@@ -200,7 +200,7 @@ def splitImage(work):
                         newPage.paste(panelImg, (0, targetHeight))
                         targetHeight += panels[panel][2]
                     newPage.save(os.path.join(path, fileExpanded[0] + '-' +
-                                              str(pageNumber) + '.png'), 'PNG')
+                                              str(pageNumber) + '.png'), 'PNG', optimize=1)
                     pageNumber += 1
             os.remove(filePath)
     except Exception:
diff --git a/kcc/image.py b/kcc/image.py
index b32bb74..212feda 100755
--- a/kcc/image.py
+++ b/kcc/image.py
@@ -144,14 +144,14 @@ class ComicPage:
                     if self.noVPV:
                         flags.append('NoVerticalPanelView')
                     if self.border:
-                        flags.append("Margins-" + str(self.border[0]) + "-" + str(self.border[1]) + "-"
-                                     + str(self.border[2]) + "-" + str(self.border[3]))
+                        flags.append('Margins-' + str(self.border[0]) + '-' + str(self.border[1]) + '-'
+                                     + str(self.border[2]) + '-' + str(self.border[3]))
                 if forcepng:
-                    filename += ".png"
-                    self.image.save(filename, "PNG", optimize=1)
+                    filename += '.png'
+                    self.image.save(filename, 'PNG', optimize=1)
                 else:
-                    filename += ".jpg"
-                    self.image.save(filename, "JPEG", optimize=1)
+                    filename += '.jpg'
+                    self.image.save(filename, 'JPEG', optimize=1, quality=80)
                 return [md5Checksum(filename), flags]
             else:
                 return None
@@ -243,7 +243,7 @@ class ComicPage:
             if self.image.size[0] <= size[0] and self.image.size[1] <= size[1]:
                 method = Image.BICUBIC
             else:
-                method = Image.ANTIALIAS
+                method = Image.LANCZOS
             self.image = self.image.resize(size, method)
             return self.image
         # If image is smaller than target resolution and upscale is off - Just expand it by adding margins
@@ -269,7 +269,7 @@ class ComicPage:
         if self.image.size[0] <= size[0] and self.image.size[1] <= size[1]:
             method = Image.BICUBIC
         else:
-            method = Image.ANTIALIAS
+            method = Image.LANCZOS
         self.image = ImageOps.fit(self.image, size, method=method, centering=(0.5, 0.5))
         return self.image
 
@@ -279,7 +279,7 @@ class ComicPage:
         # Only split if origin is not oriented the same as target
         if (width > height) != (dstwidth > dstheight):
             if rotate:
-                self.image = self.image.rotate(90)
+                self.image = self.image.rotate(90, Image.BICUBIC, True)
                 self.rotated = True
                 return None
             else:
@@ -292,9 +292,9 @@ class ComicPage:
                     # Source is portrait and target is landscape, so split by the height
                     leftbox = (0, 0, width, int(height / 2))
                     rightbox = (0, int(height / 2), width, height)
-                filename = os.path.splitext(self.filename)
-                fileone = targetdir + '/' + filename[0] + '-A' + filename[1]
-                filetwo = targetdir + '/' + filename[0] + '-B' + filename[1]
+                filename = os.path.splitext(self.filename)[0]
+                fileone = targetdir + '/' + filename + '-AAA.png'
+                filetwo = targetdir + '/' + filename + '-BBB.png'
                 try:
                     if righttoleft:
                         pageone = self.image.crop(rightbox)
@@ -302,8 +302,8 @@ class ComicPage:
                     else:
                         pageone = self.image.crop(leftbox)
                         pagetwo = self.image.crop(rightbox)
-                    pageone.save(fileone)
-                    pagetwo.save(filetwo)
+                    pageone.save(fileone, 'PNG', optimize=1)
+                    pagetwo.save(filetwo, 'PNG', optimize=1)
                 except IOError as e:
                     raise RuntimeError('Cannot write image in directory %s: %s' % (targetdir, e))
                 return fileone, filetwo
@@ -498,7 +498,7 @@ class Cover:
 
     def processExternal(self):
         self.image = self.image.convert('RGB')
-        self.image.thumbnail(self.options.profileData[1], Image.ANTIALIAS)
+        self.image.thumbnail(self.options.profileData[1], Image.LANCZOS)
         self.save(True)
 
     def trim(self):
@@ -520,6 +520,6 @@ class Cover:
             if os.path.splitext(source)[1].lower() == '.png':
                 self.image.save(self.target, "PNG", optimize=1)
             else:
-                self.image.save(self.target, "JPEG", optimize=1)
+                self.image.save(self.target, "JPEG", optimize=1, quality=80)
         except IOError:
             raise RuntimeError('Failed to save cover')
diff --git a/kcc/shared.py b/kcc/shared.py
index 7ac5163..418abf1 100644
--- a/kcc/shared.py
+++ b/kcc/shared.py
@@ -25,17 +25,11 @@ from hashlib import md5
 
 
 def getImageFileName(imgfile):
-    filename = os.path.splitext(imgfile)
-    if filename[0].startswith('.') or\
-            (filename[1].lower() != '.png' and
-             filename[1].lower() != '.jpg' and
-             filename[1].lower() != '.gif' and
-             filename[1].lower() != '.tif' and
-             filename[1].lower() != '.tiff' and
-             filename[1].lower() != '.bmp' and
-             filename[1].lower() != '.jpeg'):
+    name, ext = os.path.splitext(imgfile)
+    ext = ext.lower()
+    if name.startswith('.') or (ext != '.png' and ext != '.jpg' and ext != '.jpeg' and ext != '.gif'):
         return None
-    return filename
+    return [name, ext]
 
 
 def walkLevel(some_dir, level=1):