mirror of
https://github.com/ciromattia/kcc
synced 2026-04-23 01:19:50 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56f23ab488 | ||
|
|
996af59e00 | ||
|
|
37aa84c4aa | ||
|
|
50574632e6 | ||
|
|
0afb9e8c0b | ||
|
|
7511c7eed6 | ||
|
|
836a4146f9 |
@@ -361,6 +361,13 @@ The app relies and includes the following scripts/binaries:
|
|||||||
* Fixed problems with page order on stock KOBO CBZ reader
|
* Fixed problems with page order on stock KOBO CBZ reader
|
||||||
* Many other small bug fixes and tweaks
|
* 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
|
## KNOWN ISSUES
|
||||||
Please check [wiki page](https://github.com/ciromattia/kcc/wiki/Known-issues).
|
Please check [wiki page](https://github.com/ciromattia/kcc/wiki/Known-issues).
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
# PERFORMANCE OF THIS SOFTWARE.
|
# PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
__version__ = '4.2'
|
__version__ = '4.2.1'
|
||||||
__license__ = 'ISC'
|
__license__ = 'ISC'
|
||||||
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
# PERFORMANCE OF THIS SOFTWARE.
|
# PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
__version__ = '4.2'
|
__version__ = '4.2.1'
|
||||||
__license__ = 'ISC'
|
__license__ = 'ISC'
|
||||||
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|||||||
2
kcc.iss
2
kcc.iss
@@ -1,5 +1,5 @@
|
|||||||
#define MyAppName "Kindle Comic Converter"
|
#define MyAppName "Kindle Comic Converter"
|
||||||
#define MyAppVersion "4.2"
|
#define MyAppVersion "4.2.1"
|
||||||
#define MyAppPublisher "Ciro Mattia Gonano, Paweł Jastrzębski"
|
#define MyAppPublisher "Ciro Mattia Gonano, Paweł Jastrzębski"
|
||||||
#define MyAppURL "http://kcc.iosphe.re/"
|
#define MyAppURL "http://kcc.iosphe.re/"
|
||||||
#define MyAppExeName "KCC.exe"
|
#define MyAppExeName "KCC.exe"
|
||||||
|
|||||||
2
kcc.py
2
kcc.py
@@ -18,7 +18,7 @@
|
|||||||
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
# PERFORMANCE OF THIS SOFTWARE.
|
# PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
__version__ = '4.2'
|
__version__ = '4.2.1'
|
||||||
__license__ = 'ISC'
|
__license__ = 'ISC'
|
||||||
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
# PERFORMANCE OF THIS SOFTWARE.
|
# PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
__version__ = '4.2'
|
__version__ = '4.2.1'
|
||||||
__license__ = 'ISC'
|
__license__ = 'ISC'
|
||||||
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
@@ -491,6 +491,8 @@ class WorkerThread(QtCore.QThread):
|
|||||||
worker.signals.result.connect(self.addResult)
|
worker.signals.result.connect(self.addResult)
|
||||||
self.pool.start(worker)
|
self.pool.start(worker)
|
||||||
self.pool.waitForDone()
|
self.pool.waitForDone()
|
||||||
|
while len(self.workerOutput) != len(outputPath):
|
||||||
|
sleep(0.1)
|
||||||
self.kindlegenErrorCode = [0]
|
self.kindlegenErrorCode = [0]
|
||||||
for errors in self.workerOutput:
|
for errors in self.workerOutput:
|
||||||
if errors[0] != 0:
|
if errors[0] != 0:
|
||||||
@@ -517,6 +519,8 @@ class WorkerThread(QtCore.QThread):
|
|||||||
worker.signals.result.connect(self.addResult)
|
worker.signals.result.connect(self.addResult)
|
||||||
self.pool.start(worker)
|
self.pool.start(worker)
|
||||||
self.pool.waitForDone()
|
self.pool.waitForDone()
|
||||||
|
while len(self.workerOutput) != len(outputPath):
|
||||||
|
sleep(0.1)
|
||||||
for success in self.workerOutput:
|
for success in self.workerOutput:
|
||||||
if not success[0]:
|
if not success[0]:
|
||||||
self.errors = True
|
self.errors = True
|
||||||
@@ -1121,7 +1125,7 @@ class KCCGUI(KCC_ui.Ui_KCC):
|
|||||||
'DefaultUpscale': False, 'Label': 'KHD'},
|
'DefaultUpscale': False, 'Label': 'KHD'},
|
||||||
"Kindle": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 0,
|
"Kindle": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 0,
|
||||||
'DefaultUpscale': False, 'Label': 'K345'},
|
'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'},
|
'DefaultUpscale': False, 'Label': 'KDX'},
|
||||||
"Kindle Fire": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 0,
|
"Kindle Fire": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 0,
|
||||||
'DefaultUpscale': False, 'Label': 'KF'},
|
'DefaultUpscale': False, 'Label': 'KF'},
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
__version__ = '4.2'
|
__version__ = '4.2.1'
|
||||||
__license__ = 'ISC'
|
__license__ = 'ISC'
|
||||||
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
# PERFORMANCE OF THIS SOFTWARE.
|
# PERFORMANCE OF THIS SOFTWARE.
|
||||||
#
|
#
|
||||||
|
|
||||||
__version__ = '4.2'
|
__version__ = '4.2.1'
|
||||||
__license__ = 'ISC'
|
__license__ = 'ISC'
|
||||||
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
@@ -214,10 +214,6 @@ def buildNCX(dstdir, title, chapters, chapterNames):
|
|||||||
def buildOPF(dstdir, title, filelist, cover=None):
|
def buildOPF(dstdir, title, filelist, cover=None):
|
||||||
opffile = os.path.join(dstdir, 'OEBPS', 'content.opf')
|
opffile = os.path.join(dstdir, 'OEBPS', 'content.opf')
|
||||||
profilelabel, deviceres, palette, gamma, panelviewsize = options.profileData
|
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:
|
if options.righttoleft:
|
||||||
writingmode = "horizontal-rl"
|
writingmode = "horizontal-rl"
|
||||||
else:
|
else:
|
||||||
@@ -244,7 +240,8 @@ def buildOPF(dstdir, title, filelist, cover=None):
|
|||||||
"<meta name=\"fixed-layout\" content=\"true\"/>\n"
|
"<meta name=\"fixed-layout\" content=\"true\"/>\n"
|
||||||
"<meta name=\"rendition:orientation\" content=\"portrait\"/>\n",
|
"<meta name=\"rendition:orientation\" content=\"portrait\"/>\n",
|
||||||
"<meta name=\"orientation-lock\" content=\"portrait\"/>\n",
|
"<meta name=\"orientation-lock\" content=\"portrait\"/>\n",
|
||||||
"<meta name=\"original-resolution\" content=\"", imgres, "\"/>\n",
|
"<meta name=\"original-resolution\" content=\"",
|
||||||
|
str(deviceres[0]) + "x" + str(deviceres[1]), "\"/>\n",
|
||||||
"<meta name=\"primary-writing-mode\" content=\"", writingmode, "\"/>\n",
|
"<meta name=\"primary-writing-mode\" content=\"", writingmode, "\"/>\n",
|
||||||
"<meta name=\"ke-border-color\" content=\"#ffffff\"/>\n",
|
"<meta name=\"ke-border-color\" content=\"#ffffff\"/>\n",
|
||||||
"<meta name=\"ke-border-width\" content=\"0\"/>\n",
|
"<meta name=\"ke-border-width\" content=\"0\"/>\n",
|
||||||
@@ -428,7 +425,7 @@ def buildEPUB(path, chapterNames, tomeNumber):
|
|||||||
|
|
||||||
def imgOptimization(img, opt, hqImage=None):
|
def imgOptimization(img, opt, hqImage=None):
|
||||||
if not img.fill:
|
if not img.fill:
|
||||||
img.getImageFill(opt.webtoon)
|
img.getImageFill()
|
||||||
if not opt.webtoon:
|
if not opt.webtoon:
|
||||||
img.cropWhiteSpace()
|
img.cropWhiteSpace()
|
||||||
if opt.cutpagenumbers and not opt.webtoon:
|
if opt.cutpagenumbers and not opt.webtoon:
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
# PERFORMANCE OF THIS SOFTWARE.
|
# PERFORMANCE OF THIS SOFTWARE.
|
||||||
#
|
#
|
||||||
|
|
||||||
__version__ = '4.2'
|
__version__ = '4.2.1'
|
||||||
__license__ = 'ISC'
|
__license__ = 'ISC'
|
||||||
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|||||||
75
kcc/image.py
75
kcc/image.py
@@ -16,7 +16,7 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
__version__ = '4.2'
|
__version__ = '4.2.1'
|
||||||
__license__ = 'ISC'
|
__license__ = 'ISC'
|
||||||
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
@@ -24,6 +24,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
import os
|
import os
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from urllib.request import Request, urlopen
|
from urllib.request import Request, urlopen
|
||||||
|
from urllib.parse import quote
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
from PIL import Image, ImageOps, ImageStat, ImageChops
|
from PIL import Image, ImageOps, ImageStat, ImageChops
|
||||||
from .shared import md5Checksum
|
from .shared import md5Checksum
|
||||||
@@ -403,50 +404,44 @@ class ComicPage:
|
|||||||
|
|
||||||
def getImageHistogram(self, image):
|
def getImageHistogram(self, image):
|
||||||
histogram = image.histogram()
|
histogram = image.histogram()
|
||||||
RBGW = []
|
if histogram[0] == 0:
|
||||||
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:
|
|
||||||
return -1
|
return -1
|
||||||
|
elif histogram[255] == 0:
|
||||||
|
return 1
|
||||||
else:
|
else:
|
||||||
return False
|
return 0
|
||||||
|
|
||||||
def getImageFill(self, webtoon):
|
def getImageFill(self):
|
||||||
fill = 0
|
bw = self.image.convert('L').point(lambda x: 0 if x < 128 else 255, '1')
|
||||||
if not webtoon and not self.rotated:
|
imageBoxA = bw.getbbox()
|
||||||
# Search for horizontal solid lines
|
imageBoxB = ImageChops.invert(bw).getbbox()
|
||||||
startY = 0
|
if imageBoxA is None or imageBoxB is None:
|
||||||
while startY < self.image.size[1]:
|
surfaceB, surfaceW = 0, 0
|
||||||
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
|
|
||||||
else:
|
else:
|
||||||
# Search for vertical solid lines
|
surfaceB = (imageBoxA[2] - imageBoxA[0]) * (imageBoxA[3] - imageBoxA[1])
|
||||||
startX = 0
|
surfaceW = (imageBoxB[2] - imageBoxB[0]) * (imageBoxB[3] - imageBoxB[1])
|
||||||
while startX < self.image.size[0]:
|
if surfaceW < surfaceB:
|
||||||
if startX + 5 > self.image.size[0]:
|
self.fill = 'white'
|
||||||
startX = self.image.size[0] - 5
|
elif surfaceW > surfaceB:
|
||||||
checkSolid = self.getImageHistogram(self.image.crop((startX, 0, startX+5, self.image.size[1])))
|
|
||||||
if checkSolid:
|
|
||||||
fill += checkSolid
|
|
||||||
startX += 5
|
|
||||||
if fill > 0:
|
|
||||||
self.fill = 'black'
|
self.fill = 'black'
|
||||||
else:
|
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):
|
def isImageColor(self):
|
||||||
v = ImageStat.Stat(self.image).var
|
v = ImageStat.Stat(self.image).var
|
||||||
@@ -485,7 +480,7 @@ class Cover:
|
|||||||
self.tomeNumber = tomeNumber
|
self.tomeNumber = tomeNumber
|
||||||
if self.tomeNumber in self.options.remoteCovers:
|
if self.tomeNumber in self.options.remoteCovers:
|
||||||
try:
|
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()
|
headers={'User-Agent': 'KindleComicConverter/' + __version__})).read()
|
||||||
self.image = Image.open(BytesIO(source))
|
self.image = Image.open(BytesIO(source))
|
||||||
self.processExternal()
|
self.processExternal()
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -14,7 +14,7 @@ if version_info[0] != 3:
|
|||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
NAME = "KindleComicConverter"
|
NAME = "KindleComicConverter"
|
||||||
VERSION = "4.2"
|
VERSION = "4.2.1"
|
||||||
MAIN = "kcc.py"
|
MAIN = "kcc.py"
|
||||||
|
|
||||||
if platform == "darwin":
|
if platform == "darwin":
|
||||||
|
|||||||
Reference in New Issue
Block a user