From 836a4146f97b59c81fcf3d5dab913672d291cf2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Wed, 23 Jul 2014 20:55:31 +0200 Subject: [PATCH 1/6] MCD: Fixed small bug --- kcc/image.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kcc/image.py b/kcc/image.py index f8abfe6..fd00b90 100755 --- a/kcc/image.py +++ b/kcc/image.py @@ -24,6 +24,7 @@ __docformat__ = 'restructuredtext en' import os from io import BytesIO from urllib.request import Request, urlopen +from urllib.parse import quote from functools import reduce from PIL import Image, ImageOps, ImageStat, ImageChops from .shared import md5Checksum @@ -485,7 +486,7 @@ class Cover: self.tomeNumber = tomeNumber if self.tomeNumber in self.options.remoteCovers: try: - source = urlopen(Request(self.options.remoteCovers[self.tomeNumber], + source = urlopen(Request(quote(self.options.remoteCovers[self.tomeNumber]).replace('%3A', ':', 1), headers={'User-Agent': 'KindleComicConverter/' + __version__})).read() self.image = Image.open(BytesIO(source)) self.processExternal() From 7511c7eed630992ffcfb8f4017f980b17afa0931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Tue, 29 Jul 2014 19:59:21 +0200 Subject: [PATCH 2/6] Kindle DX: Changed default output format to CBZ --- kcc/KCC_gui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kcc/KCC_gui.py b/kcc/KCC_gui.py index 30a4e91..8cf5c3b 100644 --- a/kcc/KCC_gui.py +++ b/kcc/KCC_gui.py @@ -1121,7 +1121,7 @@ class KCCGUI(KCC_ui.Ui_KCC): 'DefaultUpscale': False, 'Label': 'KHD'}, "Kindle": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 0, 'DefaultUpscale': False, 'Label': 'K345'}, - "Kindle DX/DXG": {'Quality': False, 'ForceExpert': False, 'DefaultFormat': 0, + "Kindle DX/DXG": {'Quality': False, 'ForceExpert': False, 'DefaultFormat': 2, 'DefaultUpscale': False, 'Label': 'KDX'}, "Kindle Fire": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 0, 'DefaultUpscale': False, 'Label': 'KF'}, From 0afb9e8c0b0e97f7a1dbdc5f7f7a8ca9c1fb8225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Thu, 31 Jul 2014 18:00:44 +0200 Subject: [PATCH 3/6] Kindle: Fixed high quality mode (close #106) --- kcc/comic2ebook.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index 73b798b..77a4c85 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -214,10 +214,6 @@ def buildNCX(dstdir, title, chapters, chapterNames): def buildOPF(dstdir, title, filelist, cover=None): opffile = os.path.join(dstdir, 'OEBPS', 'content.opf') profilelabel, deviceres, palette, gamma, panelviewsize = options.profileData - if options.quality == 1: - imgres = str(panelviewsize[0]) + "x" + str(panelviewsize[1]) - else: - imgres = str(deviceres[0]) + "x" + str(deviceres[1]) if options.righttoleft: writingmode = "horizontal-rl" else: @@ -244,7 +240,8 @@ def buildOPF(dstdir, title, filelist, cover=None): "\n" "\n", "\n", - "\n", + "\n", "\n", "\n", "\n", From 50574632e6c2dd987cff8a0510cac3a7c5741470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Fri, 1 Aug 2014 07:23:55 +0200 Subject: [PATCH 4/6] Replaced margin color detection algorithm --- kcc/comic2ebook.py | 2 +- kcc/image.py | 70 +++++++++++++++++++++------------------------- 2 files changed, 33 insertions(+), 39 deletions(-) diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index 77a4c85..bc18b5e 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -425,7 +425,7 @@ def buildEPUB(path, chapterNames, tomeNumber): def imgOptimization(img, opt, hqImage=None): if not img.fill: - img.getImageFill(opt.webtoon) + img.getImageFill() if not opt.webtoon: img.cropWhiteSpace() if opt.cutpagenumbers and not opt.webtoon: diff --git a/kcc/image.py b/kcc/image.py index fd00b90..fd7379c 100755 --- a/kcc/image.py +++ b/kcc/image.py @@ -404,50 +404,44 @@ class ComicPage: def getImageHistogram(self, image): histogram = image.histogram() - RBGW = [] - pixelCount = 0 - for i in range(256): - pixelCount += histogram[i] + histogram[256 + i] + histogram[512 + i] - RBGW.append(histogram[i] + histogram[256 + i] + histogram[512 + i]) - white = 0 - black = 0 - for i in range(251, 256): - white += RBGW[i] - for i in range(5): - black += RBGW[i] - if black > pixelCount*0.8 and white == 0: - return 1 - elif white > pixelCount*0.8 and black == 0: + if histogram[0] == 0: return -1 + elif histogram[255] == 0: + return 1 else: - return False + return 0 - def getImageFill(self, webtoon): - fill = 0 - if not webtoon and not self.rotated: - # Search for horizontal solid lines - startY = 0 - while startY < self.image.size[1]: - if startY + 5 > self.image.size[1]: - startY = self.image.size[1] - 5 - checkSolid = self.getImageHistogram(self.image.crop((0, startY, self.image.size[0], startY+5))) - if checkSolid: - fill += checkSolid - startY += 5 + def getImageFill(self): + bw = self.image.convert('L').point(lambda x: 0 if x < 128 else 255, '1') + imageBoxA = bw.getbbox() + imageBoxB = ImageChops.invert(bw).getbbox() + if imageBoxA is None or imageBoxB is None: + surfaceB, surfaceW = 0, 0 else: - # Search for vertical solid lines - startX = 0 - while startX < self.image.size[0]: - if startX + 5 > self.image.size[0]: - startX = self.image.size[0] - 5 - checkSolid = self.getImageHistogram(self.image.crop((startX, 0, startX+5, self.image.size[1]))) - if checkSolid: - fill += checkSolid - startX += 5 - if fill > 0: + surfaceB = (imageBoxA[2] - imageBoxA[0]) * (imageBoxA[3] - imageBoxA[1]) + surfaceW = (imageBoxB[2] - imageBoxB[0]) * (imageBoxB[3] - imageBoxB[1]) + if surfaceW < surfaceB: + self.fill = 'white' + elif surfaceW > surfaceB: self.fill = 'black' else: - self.fill = 'white' + fill = 0 + startY = 0 + while startY < bw.size[1]: + if startY + 5 > bw.size[1]: + startY = bw.size[1] - 5 + fill += self.getImageHistogram(bw.crop((0, startY, bw.size[0], startY+5))) + startY += 5 + startX = 0 + while startX < bw.size[0]: + if startX + 5 > bw.size[0]: + startX = bw.size[0] - 5 + fill += self.getImageHistogram(bw.crop((startX, 0, startX+5, bw.size[1]))) + startX += 5 + if fill > 0: + self.fill = 'black' + else: + self.fill = 'white' def isImageColor(self): v = ImageStat.Stat(self.image).var From 37aa84c4aa86592483b30df1dbd56818096a3d4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Sat, 2 Aug 2014 07:54:15 +0200 Subject: [PATCH 5/6] Fixed MOBI processing anomalies --- kcc/KCC_gui.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kcc/KCC_gui.py b/kcc/KCC_gui.py index 8cf5c3b..b798c6c 100644 --- a/kcc/KCC_gui.py +++ b/kcc/KCC_gui.py @@ -491,6 +491,8 @@ class WorkerThread(QtCore.QThread): worker.signals.result.connect(self.addResult) self.pool.start(worker) self.pool.waitForDone() + while len(self.workerOutput) != len(outputPath): + sleep(0.1) self.kindlegenErrorCode = [0] for errors in self.workerOutput: if errors[0] != 0: @@ -517,6 +519,8 @@ class WorkerThread(QtCore.QThread): worker.signals.result.connect(self.addResult) self.pool.start(worker) self.pool.waitForDone() + while len(self.workerOutput) != len(outputPath): + sleep(0.1) for success in self.workerOutput: if not success[0]: self.errors = True From 996af59e004846d7158ec92c1845040ba34eeecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Sun, 3 Aug 2014 11:21:43 +0200 Subject: [PATCH 6/6] Updated README + version bump --- README.md | 7 +++++++ kcc-c2e.py | 2 +- kcc-c2p.py | 2 +- kcc.iss | 2 +- kcc.py | 2 +- kcc/KCC_gui.py | 2 +- kcc/__init__.py | 2 +- kcc/comic2ebook.py | 2 +- kcc/comic2panel.py | 2 +- kcc/image.py | 2 +- setup.py | 2 +- setup.sh | 2 +- 12 files changed, 18 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index eef9924..f0f59af 100644 --- a/README.md +++ b/README.md @@ -361,6 +361,13 @@ The app relies and includes the following scripts/binaries: * Fixed problems with page order on stock KOBO CBZ reader * Many other small bug fixes and tweaks +####4.2.1: +* Improved margin color detection +* Fixed random crashes of MOBI processing step +* Fixed resizing problems in high quality mode +* Fixed some MCD support bugs +* Default output format for Kindle DX is now CBZ + ## KNOWN ISSUES Please check [wiki page](https://github.com/ciromattia/kcc/wiki/Known-issues). diff --git a/kcc-c2e.py b/kcc-c2e.py index a89fe1a..466624d 100755 --- a/kcc-c2e.py +++ b/kcc-c2e.py @@ -18,7 +18,7 @@ # TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -__version__ = '4.2' +__version__ = '4.2.1' __license__ = 'ISC' __copyright__ = '2012-2014, Ciro Mattia Gonano , Pawel Jastrzebski ' __docformat__ = 'restructuredtext en' diff --git a/kcc-c2p.py b/kcc-c2p.py index a50500c..1703413 100755 --- a/kcc-c2p.py +++ b/kcc-c2p.py @@ -18,7 +18,7 @@ # TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -__version__ = '4.2' +__version__ = '4.2.1' __license__ = 'ISC' __copyright__ = '2012-2014, Ciro Mattia Gonano , Pawel Jastrzebski ' __docformat__ = 'restructuredtext en' diff --git a/kcc.iss b/kcc.iss index 5b7b067..3d63f08 100644 --- a/kcc.iss +++ b/kcc.iss @@ -1,5 +1,5 @@ #define MyAppName "Kindle Comic Converter" -#define MyAppVersion "4.2" +#define MyAppVersion "4.2.1" #define MyAppPublisher "Ciro Mattia Gonano, Paweł Jastrzębski" #define MyAppURL "http://kcc.iosphe.re/" #define MyAppExeName "KCC.exe" diff --git a/kcc.py b/kcc.py index 9e546b9..a0d5fa2 100755 --- a/kcc.py +++ b/kcc.py @@ -18,7 +18,7 @@ # TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -__version__ = '4.2' +__version__ = '4.2.1' __license__ = 'ISC' __copyright__ = '2012-2014, Ciro Mattia Gonano , Pawel Jastrzebski ' __docformat__ = 'restructuredtext en' diff --git a/kcc/KCC_gui.py b/kcc/KCC_gui.py index b798c6c..9ddace4 100644 --- a/kcc/KCC_gui.py +++ b/kcc/KCC_gui.py @@ -17,7 +17,7 @@ # TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -__version__ = '4.2' +__version__ = '4.2.1' __license__ = 'ISC' __copyright__ = '2012-2014, Ciro Mattia Gonano , Pawel Jastrzebski ' __docformat__ = 'restructuredtext en' diff --git a/kcc/__init__.py b/kcc/__init__.py index 34c10c7..f204eb3 100644 --- a/kcc/__init__.py +++ b/kcc/__init__.py @@ -1,4 +1,4 @@ -__version__ = '4.2' +__version__ = '4.2.1' __license__ = 'ISC' __copyright__ = '2012-2014, Ciro Mattia Gonano , Pawel Jastrzebski ' __docformat__ = 'restructuredtext en' \ No newline at end of file diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index bc18b5e..9b7e8c3 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -18,7 +18,7 @@ # PERFORMANCE OF THIS SOFTWARE. # -__version__ = '4.2' +__version__ = '4.2.1' __license__ = 'ISC' __copyright__ = '2012-2014, Ciro Mattia Gonano , Pawel Jastrzebski ' __docformat__ = 'restructuredtext en' diff --git a/kcc/comic2panel.py b/kcc/comic2panel.py index d506cac..e0e9191 100644 --- a/kcc/comic2panel.py +++ b/kcc/comic2panel.py @@ -18,7 +18,7 @@ # PERFORMANCE OF THIS SOFTWARE. # -__version__ = '4.2' +__version__ = '4.2.1' __license__ = 'ISC' __copyright__ = '2012-2014, Ciro Mattia Gonano , Pawel Jastrzebski ' __docformat__ = 'restructuredtext en' diff --git a/kcc/image.py b/kcc/image.py index fd7379c..a04b2de 100755 --- a/kcc/image.py +++ b/kcc/image.py @@ -16,7 +16,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -__version__ = '4.2' +__version__ = '4.2.1' __license__ = 'ISC' __copyright__ = '2012-2014, Ciro Mattia Gonano , Pawel Jastrzebski ' __docformat__ = 'restructuredtext en' diff --git a/setup.py b/setup.py index 5f90bec..f2a2828 100755 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ if version_info[0] != 3: exit(1) NAME = "KindleComicConverter" -VERSION = "4.2" +VERSION = "4.2.1" MAIN = "kcc.py" if platform == "darwin": diff --git a/setup.sh b/setup.sh index bd69758..eacc5c4 100755 --- a/setup.sh +++ b/setup.sh @@ -1,7 +1,7 @@ #!/bin/bash # Linux Python package build script -VERSION="4.2" +VERSION="4.2.1" cp kcc.py __main__.py zip kcc.zip __main__.py kcc/*.py