mirror of
https://github.com/ciromattia/kcc
synced 2025-12-13 09:46:25 +00:00
Web...toon mode improvements
This commit is contained in:
@@ -93,13 +93,13 @@
|
||||
<property name="text">
|
||||
<string>Stretch/Upscale</string>
|
||||
</property>
|
||||
<property name="tristate">
|
||||
<property name="tristate">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="WebstripBox">
|
||||
<widget class="QCheckBox" name="WebtoonBox">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>11</pointsize>
|
||||
@@ -109,10 +109,10 @@
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p><span style=" font-weight:600;">EXPERIMENTAL!<br/></span>Enable auto-splitting of webstrips like <span style=" font-style:italic;">Tower of God</span> or <span style=" font-style:italic;">Noblesse</span>.<br/>Files with a low width, high height and vertical panel flow.</p></body></html></string>
|
||||
<string><html><head/><body><p><span style=" font-weight:600;">EXPERIMENTAL!<br/></span>Enable auto-splitting of webtoons like <span style=" font-style:italic;">Tower of God</span> or <span style=" font-style:italic;">Noblesse</span>.<br/>Pages with a low width, high height and vertical panel flow.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Webstrip mode</string>
|
||||
<string>Webtoon mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
6
KCC.ui
6
KCC.ui
@@ -92,15 +92,15 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="WebstripBox">
|
||||
<widget class="QCheckBox" name="WebtoonBox">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p><span style=" font-weight:600;">EXPERIMENTAL!<br/></span>Enable auto-splitting of webstrips like <span style=" font-style:italic;">Tower of God</span> or <span style=" font-style:italic;">Noblesse</span>.<br/>Files with a low width, high height and vertical panel flow.</p></body></html></string>
|
||||
<string><html><head/><body><p><span style=" font-weight:600;">EXPERIMENTAL!<br/></span>Enable auto-splitting of webtoons like <span style=" font-style:italic;">Tower of God</span> or <span style=" font-style:italic;">Noblesse</span>.<br/>Pages with a low width, high height and vertical panel flow.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Webstrip mode</string>
|
||||
<string>Webtoon mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -73,7 +73,7 @@ Options:
|
||||
-m, --manga-style Manga style (Right-to-left reading and splitting)
|
||||
|
||||
EXPERIMENTAL:
|
||||
-w, --webstrip Webstrip processing mode
|
||||
-w, --webtoon Webtoon processing mode
|
||||
|
||||
OUTPUT SETTINGS:
|
||||
-o OUTPUT, --output=OUTPUT
|
||||
@@ -249,7 +249,7 @@ The app relies and includes the following scripts/binaries:
|
||||
|
||||
####3.2:
|
||||
* Too big EPUB files are now splitted before conversion to MOBI
|
||||
* Added experimental parser of manga webstrips
|
||||
* Added experimental parser of manga webtoons
|
||||
* Improved error handling
|
||||
|
||||
## KNOWN ISSUES
|
||||
|
||||
@@ -138,8 +138,8 @@ class WorkerThread(QtCore.QThread):
|
||||
argv.append("--upscale")
|
||||
if GUI.NoDitheringBox.isChecked():
|
||||
argv.append("--forcepng")
|
||||
if GUI.WebstripBox.isChecked():
|
||||
argv.append("--webstrip")
|
||||
if GUI.WebtoonBox.isChecked():
|
||||
argv.append("--webtoon")
|
||||
if float(self.parent.GammaValue) > 0.09:
|
||||
argv.append("--gamma=" + self.parent.GammaValue)
|
||||
if str(GUI.FormatBox.currentText()) == 'CBZ':
|
||||
@@ -429,16 +429,17 @@ class Ui_KCC(object):
|
||||
GUI.GammaLabel.setText('Gamma: ' + str(value))
|
||||
self.GammaValue = value
|
||||
|
||||
def toggleWebstripBox(self, value):
|
||||
def toggleWebtoonBox(self, value):
|
||||
if value:
|
||||
GUI.RotateBox.setEnabled(False)
|
||||
GUI.RotateBox.setChecked(True)
|
||||
GUI.NoRotateBox.setEnabled(False)
|
||||
GUI.NoRotateBox.setChecked(True)
|
||||
GUI.QualityBox.setEnabled(False)
|
||||
GUI.QualityBox.setChecked(False)
|
||||
GUI.BorderBox.setEnabled(False)
|
||||
GUI.BorderBox.setChecked(False)
|
||||
self.addMessage('If images are color setting <i>Gamma</i> to 1.0 is recommended.', 'info')
|
||||
else:
|
||||
GUI.RotateBox.setEnabled(True)
|
||||
GUI.NoRotateBox.setEnabled(True)
|
||||
GUI.QualityBox.setEnabled(True)
|
||||
GUI.BorderBox.setEnabled(True)
|
||||
|
||||
@@ -544,7 +545,7 @@ class Ui_KCC(object):
|
||||
'UpscaleBox': GUI.UpscaleBox.checkState(),
|
||||
'NoRotateBox': GUI.NoRotateBox.checkState(),
|
||||
'BorderBox': GUI.BorderBox.checkState(),
|
||||
'WebstripBox': GUI.WebstripBox.checkState(),
|
||||
'WebtoonBox': GUI.WebtoonBox.checkState(),
|
||||
'NoDitheringBox': GUI.NoDitheringBox.checkState(),
|
||||
'ColorBox': GUI.ColorBox.checkState(),
|
||||
'customWidth': GUI.customWidth.text(),
|
||||
@@ -606,7 +607,7 @@ class Ui_KCC(object):
|
||||
GUI.ConvertButton.clicked.connect(self.convertStart)
|
||||
GUI.GammaSlider.valueChanged.connect(self.changeGamma)
|
||||
GUI.NoRotateBox.stateChanged.connect(self.toggleNoSplitRotate)
|
||||
GUI.WebstripBox.stateChanged.connect(self.toggleWebstripBox)
|
||||
GUI.WebtoonBox.stateChanged.connect(self.toggleWebtoonBox)
|
||||
GUI.DeviceBox.activated.connect(self.changeDevice)
|
||||
KCC.connect(self.worker, QtCore.SIGNAL("progressBarTick"), self.updateProgressbar)
|
||||
KCC.connect(self.worker, QtCore.SIGNAL("modeConvert"), self.modeConvert)
|
||||
@@ -639,7 +640,7 @@ class Ui_KCC(object):
|
||||
elif str(option) == "GammaSlider":
|
||||
GUI.GammaSlider.setValue(int(self.options[option]))
|
||||
self.changeGamma(int(self.options[option]))
|
||||
elif str(option) == "StretchBox":
|
||||
elif str(option) == "StretchBox" or str(option) == "WebstripBox":
|
||||
pass
|
||||
else:
|
||||
eval('GUI.' + str(option)).setCheckState(self.options[option])
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# Form implementation generated from reading ui file 'KCC.ui'
|
||||
#
|
||||
# Created: Mon Aug 12 13:54:39 2013
|
||||
# Created: Wed Aug 14 08:39:46 2013
|
||||
# by: PyQt4 UI code generator 4.10.2
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
@@ -58,10 +58,10 @@ class Ui_KCC(object):
|
||||
self.UpscaleBox.setTristate(True)
|
||||
self.UpscaleBox.setObjectName(_fromUtf8("UpscaleBox"))
|
||||
self.gridLayout.addWidget(self.UpscaleBox, 1, 1, 1, 1)
|
||||
self.WebstripBox = QtGui.QCheckBox(self.OptionsAdvanced)
|
||||
self.WebstripBox.setFocusPolicy(QtCore.Qt.NoFocus)
|
||||
self.WebstripBox.setObjectName(_fromUtf8("WebstripBox"))
|
||||
self.gridLayout.addWidget(self.WebstripBox, 3, 1, 1, 1)
|
||||
self.WebtoonBox = QtGui.QCheckBox(self.OptionsAdvanced)
|
||||
self.WebtoonBox.setFocusPolicy(QtCore.Qt.NoFocus)
|
||||
self.WebtoonBox.setObjectName(_fromUtf8("WebtoonBox"))
|
||||
self.gridLayout.addWidget(self.WebtoonBox, 3, 1, 1, 1)
|
||||
self.NoDitheringBox = QtGui.QCheckBox(self.OptionsAdvanced)
|
||||
self.NoDitheringBox.setFocusPolicy(QtCore.Qt.NoFocus)
|
||||
self.NoDitheringBox.setObjectName(_fromUtf8("NoDitheringBox"))
|
||||
@@ -266,8 +266,8 @@ class Ui_KCC(object):
|
||||
self.ProcessingBox.setText(_translate("KCC", "No optimisation", None))
|
||||
self.UpscaleBox.setToolTip(_translate("KCC", "<html><head/><body><p><span style=\" font-weight:600; text-decoration: underline;\">Unchecked - Nothing<br/></span>Images smaller than device resolution will not be resized.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Indeterminate - Stretching<br/></span>Images smaller than device resolution will be resized. Aspect ratio will be not preserved.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Checked - Upscaling<br/></span>Images smaller than device resolution will be resized. Aspect ratio will be preserved.</p></body></html>", None))
|
||||
self.UpscaleBox.setText(_translate("KCC", "Stretch/Upscale", None))
|
||||
self.WebstripBox.setToolTip(_translate("KCC", "<html><head/><body><p><span style=\" font-weight:600;\">EXPERIMENTAL!<br/></span>Enable auto-splitting of webstrips like <span style=\" font-style:italic;\">Tower of God</span> or <span style=\" font-style:italic;\">Noblesse</span>.<br/>Files with a low width, high height and vertical panel flow.</p></body></html>", None))
|
||||
self.WebstripBox.setText(_translate("KCC", "Webstrip mode", None))
|
||||
self.WebtoonBox.setToolTip(_translate("KCC", "<html><head/><body><p><span style=\" font-weight:600;\">EXPERIMENTAL!<br/></span>Enable auto-splitting of webtoons like <span style=\" font-style:italic;\">Tower of God</span> or <span style=\" font-style:italic;\">Noblesse</span>.<br/>Pages with a low width, high height and vertical panel flow.</p></body></html>", None))
|
||||
self.WebtoonBox.setText(_translate("KCC", "Webtoon mode", None))
|
||||
self.NoDitheringBox.setToolTip(_translate("KCC", "<html><head/><body><p>Create PNG files instead JPEG.<br/><span style=\" font-weight:600;\">Only for non-Kindle devices!</span></p></body></html>", None))
|
||||
self.NoDitheringBox.setText(_translate("KCC", "PNG output", None))
|
||||
self.BorderBox.setToolTip(_translate("KCC", "Fill space around images with black color.", None))
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# Form implementation generated from reading ui file 'KCC-OSX.ui'
|
||||
#
|
||||
# Created: Mon Aug 12 13:54:37 2013
|
||||
# Created: Wed Aug 14 08:39:45 2013
|
||||
# by: PyQt4 UI code generator 4.10.2
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
@@ -63,13 +63,13 @@ class Ui_KCC(object):
|
||||
self.UpscaleBox.setTristate(True)
|
||||
self.UpscaleBox.setObjectName(_fromUtf8("UpscaleBox"))
|
||||
self.gridLayout.addWidget(self.UpscaleBox, 1, 1, 1, 1)
|
||||
self.WebstripBox = QtGui.QCheckBox(self.OptionsAdvanced)
|
||||
self.WebtoonBox = QtGui.QCheckBox(self.OptionsAdvanced)
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(11)
|
||||
self.WebstripBox.setFont(font)
|
||||
self.WebstripBox.setFocusPolicy(QtCore.Qt.NoFocus)
|
||||
self.WebstripBox.setObjectName(_fromUtf8("WebstripBox"))
|
||||
self.gridLayout.addWidget(self.WebstripBox, 3, 1, 1, 1)
|
||||
self.WebtoonBox.setFont(font)
|
||||
self.WebtoonBox.setFocusPolicy(QtCore.Qt.NoFocus)
|
||||
self.WebtoonBox.setObjectName(_fromUtf8("WebtoonBox"))
|
||||
self.gridLayout.addWidget(self.WebtoonBox, 3, 1, 1, 1)
|
||||
self.NoDitheringBox = QtGui.QCheckBox(self.OptionsAdvanced)
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(11)
|
||||
@@ -324,8 +324,8 @@ class Ui_KCC(object):
|
||||
self.ProcessingBox.setText(_translate("KCC", "No optimisation", None))
|
||||
self.UpscaleBox.setToolTip(_translate("KCC", "<html><head/><body><p><span style=\" font-weight:600; text-decoration: underline;\">Unchecked - Nothing<br/></span>Images smaller than device resolution will not be resized.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Indeterminate - Stretching<br/></span>Images smaller than device resolution will be resized. Aspect ratio will be not preserved.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Checked - Upscaling<br/></span>Images smaller than device resolution will be resized. Aspect ratio will be preserved.</p></body></html>", None))
|
||||
self.UpscaleBox.setText(_translate("KCC", "Stretch/Upscale", None))
|
||||
self.WebstripBox.setToolTip(_translate("KCC", "<html><head/><body><p><span style=\" font-weight:600;\">EXPERIMENTAL!<br/></span>Enable auto-splitting of webstrips like <span style=\" font-style:italic;\">Tower of God</span> or <span style=\" font-style:italic;\">Noblesse</span>.<br/>Files with a low width, high height and vertical panel flow.</p></body></html>", None))
|
||||
self.WebstripBox.setText(_translate("KCC", "Webstrip mode", None))
|
||||
self.WebtoonBox.setToolTip(_translate("KCC", "<html><head/><body><p><span style=\" font-weight:600;\">EXPERIMENTAL!<br/></span>Enable auto-splitting of webtoons like <span style=\" font-style:italic;\">Tower of God</span> or <span style=\" font-style:italic;\">Noblesse</span>.<br/>Pages with a low width, high height and vertical panel flow.</p></body></html>", None))
|
||||
self.WebtoonBox.setText(_translate("KCC", "Webtoon mode", None))
|
||||
self.NoDitheringBox.setToolTip(_translate("KCC", "<html><head/><body><p><span style=\" font-size:12pt;\">Create PNG files instead JPEG.<br/></span><span style=\" font-size:12pt; font-weight:600;\">Only for non-Kindle devices!</span></p></body></html>", None))
|
||||
self.NoDitheringBox.setText(_translate("KCC", "PNG output", None))
|
||||
self.BorderBox.setToolTip(_translate("KCC", "<html><head/><body><p><span style=\" font-size:12pt;\">Fill space around images with black color.</span></p></body></html>", None))
|
||||
|
||||
@@ -323,9 +323,9 @@ def getImageFileName(imgfile):
|
||||
|
||||
|
||||
def applyImgOptimization(img, isSplit, toRight, options, overrideQuality=5):
|
||||
if not options.webstrip:
|
||||
if not options.webtoon:
|
||||
img.cropWhiteSpace(10.0)
|
||||
if options.cutpagenumbers and not options.webstrip:
|
||||
if options.cutpagenumbers and not options.webtoon:
|
||||
img.cutPageNumber()
|
||||
img.optimizeImage(options.gamma)
|
||||
if overrideQuality != 5:
|
||||
@@ -849,8 +849,8 @@ def main(argv=None, qtGUI=None):
|
||||
help="Outputs a CBZ archive and does not generate EPUB")
|
||||
outputOptions.add_option("--batchsplit", action="store_true", dest="batchsplit", default=False,
|
||||
help="Split output into multiple files"),
|
||||
experimentalOptions.add_option("-w", "--webstrip", action="store_true", dest="webstrip", default=False,
|
||||
help="Webstrip processing mode"),
|
||||
experimentalOptions.add_option("-w", "--webtoon", action="store_true", dest="webtoon", default=False,
|
||||
help="Webtoon processing mode"),
|
||||
processingOptions.add_option("--blackborders", action="store_true", dest="black_borders", default=False,
|
||||
help="Use black borders instead of white ones")
|
||||
processingOptions.add_option("--forcecolor", action="store_true", dest="forcecolor", default=False,
|
||||
@@ -896,7 +896,7 @@ def main(argv=None, qtGUI=None):
|
||||
parser.print_help()
|
||||
return
|
||||
path = getWorkFolder(args[0])
|
||||
if options.webstrip:
|
||||
if options.webtoon:
|
||||
if GUI:
|
||||
GUI.emit(QtCore.SIGNAL("progressBarTick"), 'status', 'Splitting images')
|
||||
if options.customheight > 0:
|
||||
@@ -967,9 +967,9 @@ def getOutputFilename(srcpath, wantedname, ext, tomeNumber):
|
||||
|
||||
def checkOptions():
|
||||
global options
|
||||
# Webstrip mode mandatory options
|
||||
if options.webstrip:
|
||||
options.rotate = True
|
||||
# Webtoon mode mandatory options
|
||||
if options.webtoon:
|
||||
options.nosplitrotate = True
|
||||
options.black_borders = False
|
||||
options.quality = 0
|
||||
# Landscape mode is only supported by Kindle Touch and Paperwhite.
|
||||
|
||||
@@ -110,8 +110,8 @@ def splitImage(work):
|
||||
name = work[1]
|
||||
options = splitImage.options
|
||||
# Harcoded options
|
||||
threshold = 10.0
|
||||
delta = 10
|
||||
threshold = 0.5
|
||||
delta = 15
|
||||
print ".",
|
||||
splitImage.queue.put(".")
|
||||
fileExpanded = os.path.splitext(name)
|
||||
@@ -126,7 +126,7 @@ def splitImage(work):
|
||||
|
||||
# Find panels
|
||||
y1 = 0
|
||||
y2 = 10
|
||||
y2 = 15
|
||||
panels = []
|
||||
while y2 < heightImg:
|
||||
while ImageStat.Stat(image.crop([0, y1, widthImg, y2])).var[0] < threshold and y2 < heightImg:
|
||||
@@ -178,14 +178,15 @@ def splitImage(work):
|
||||
targetHeight = 0
|
||||
for panel in page:
|
||||
pageHeight += panels[panel][2]
|
||||
newPage = Image.new('RGB', (widthImg, pageHeight))
|
||||
for panel in page:
|
||||
panelImg = image.crop([0, panels[panel][0], widthImg, panels[panel][1]])
|
||||
newPage.paste(panelImg, (0, targetHeight))
|
||||
targetHeight += panels[panel][2]
|
||||
newPage.save(os.path.join(path, fileExpanded[0] + '-' +
|
||||
str(pageNumber) + '-' + getImageFill(newPage) + '.png'), 'PNG')
|
||||
pageNumber += 1
|
||||
if pageHeight > delta:
|
||||
newPage = Image.new('RGB', (widthImg, pageHeight))
|
||||
for panel in page:
|
||||
panelImg = image.crop([0, panels[panel][0], widthImg, panels[panel][1]])
|
||||
newPage.paste(panelImg, (0, targetHeight))
|
||||
targetHeight += panels[panel][2]
|
||||
newPage.save(os.path.join(path, fileExpanded[0] + '-' +
|
||||
str(pageNumber) + '-' + getImageFill(newPage) + '.png'), 'PNG')
|
||||
pageNumber += 1
|
||||
os.remove(os.path.join(path, name))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user