diff options
| author | Paweł Jastrzębski <[email protected]> | 2017-03-22 10:46:58 +0100 |
|---|---|---|
| committer | Paweł Jastrzębski <[email protected]> | 2017-03-22 10:46:58 +0100 |
| commit | 283d6101cdc43921b6190d831a1908245836f230 (patch) | |
| tree | 2cbe84af5971a653717678a6d6bad542f21471ef | |
| parent | Overhauled webtoon splitter (diff) | |
| download | kcc-283d6101cdc43921b6190d831a1908245836f230.tar.gz kcc-283d6101cdc43921b6190d831a1908245836f230.tar.bz2 kcc-283d6101cdc43921b6190d831a1908245836f230.zip | |
Reimplemented HQ Panel View (close #223)
| -rw-r--r-- | gui/KCC.ui | 62 | ||||
| -rw-r--r-- | kindlecomicconverter/KCC_gui.py | 23 | ||||
| -rw-r--r-- | kindlecomicconverter/KCC_ui.py | 7 | ||||
| -rwxr-xr-x | kindlecomicconverter/comic2ebook.py | 19 | ||||
| -rwxr-xr-x | kindlecomicconverter/image.py | 2 |
5 files changed, 97 insertions, 16 deletions
diff --git a/gui/KCC.ui b/gui/KCC.ui index 5dc8697..56cc2b6 100644 --- a/gui/KCC.ui +++ b/gui/KCC.ui @@ -66,7 +66,16 @@ <bool>false</bool> </property> <layout class="QGridLayout" name="gridLayout_3"> - <property name="margin"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> <number>0</number> </property> <item row="0" column="2"> @@ -127,7 +136,16 @@ <item row="4" column="0" colspan="2"> <widget class="QWidget" name="optionWidget" native="true"> <layout class="QGridLayout" name="gridLayout_2"> - <property name="margin"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> <number>0</number> </property> <item row="0" column="0"> @@ -156,10 +174,13 @@ <item row="0" column="2"> <widget class="QCheckBox" name="qualityBox"> <property name="toolTip"> - <string><html><head/><body><p style=\'white-space:pre\'><span style=\" font-weight:600; text-decoration: underline;\">Unchecked - 4 panels<br/></span>Zoom each corner separately.</p><p style=\'white-space:pre\'><span style=\" font-weight:600; text-decoration: underline;\">Checked - 2 panels<br/></span>Zoom only the top and bottom of the page.</p></body></html></string> + <string><html><head/><body><p style='white-space:pre'><span style=" font-weight:600; text-decoration: underline;">Unchecked - 4 panels<br/></span>Zoom each corner separately.</p><p style='white-space:pre'><span style=" font-weight:600; text-decoration: underline;">Indeterminate - 2 panels<br/></span>Zoom only the top and bottom of the page.</p><p><span style=" font-weight:600; text-decoration: underline;">Checked - 4 high quality panels<br/></span>Zoom each corner separately. Try to increase the quality of magnification. Check wiki for more details.</p></body></html></string> </property> <property name="text"> - <string>Panel View 4/2</string> + <string>Panel View 4/2/HQ</string> + </property> + <property name="tristate"> + <bool>true</bool> </property> </widget> </item> @@ -238,7 +259,16 @@ <bool>false</bool> </property> <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="margin"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> <number>0</number> </property> <item> @@ -267,7 +297,16 @@ <item row="0" column="0" colspan="2"> <widget class="QWidget" name="toolWidget" native="true"> <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="margin"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> <number>0</number> </property> <item> @@ -316,7 +355,16 @@ </sizepolicy> </property> <layout class="QGridLayout" name="gridLayout_4"> - <property name="margin"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> <number>0</number> </property> <item row="0" column="0"> diff --git a/kindlecomicconverter/KCC_gui.py b/kindlecomicconverter/KCC_gui.py index 5cf29d7..a8c7449 100644 --- a/kindlecomicconverter/KCC_gui.py +++ b/kindlecomicconverter/KCC_gui.py @@ -254,8 +254,10 @@ class WorkerThread(QtCore.QThread): options.splitter = 2 elif GUI.rotateBox.checkState() == 2: options.splitter = 1 - if GUI.qualityBox.isChecked(): + if GUI.qualityBox.checkState() == 1: options.autoscale = True + elif GUI.qualityBox.checkState() == 2: + options.hq = True if GUI.webtoonBox.isChecked(): options.webtoon = True if GUI.upscaleBox.checkState() == 1: @@ -613,6 +615,18 @@ class KCCGUI(KCC_ui.Ui_mainWindow): GUI.rotateBox.setEnabled(True) GUI.upscaleBox.setEnabled(True) + def togglequalityBox(self, value): + profile = GUI.profiles[str(GUI.deviceBox.currentText())] + if value == 2: + if profile['Label'] in ['KV']: + self.addMessage('This option is intended for older Kindle models.', 'warning') + self.addMessage('It might not provide any quality increase in this case.', 'warning') + GUI.upscaleBox.setEnabled(False) + GUI.upscaleBox.setChecked(True) + else: + GUI.upscaleBox.setEnabled(True) + GUI.upscaleBox.setChecked(profile['DefaultUpscale']) + def changeGamma(self, value): valueRaw = int(5 * round(float(value) / 5)) value = '%.2f' % (float(valueRaw) / 100) @@ -634,7 +648,8 @@ class KCCGUI(KCC_ui.Ui_mainWindow): self.changeFormat() GUI.gammaSlider.setValue(0) self.changeGamma(0) - GUI.qualityBox.setEnabled(profile['PVOptions']) + if not GUI.webtoonBox.isChecked(): + GUI.qualityBox.setEnabled(profile['PVOptions']) GUI.upscaleBox.setChecked(profile['DefaultUpscale']) if not profile['PVOptions']: GUI.qualityBox.setChecked(False) @@ -648,7 +663,8 @@ class KCCGUI(KCC_ui.Ui_mainWindow): GUI.formatBox.setCurrentIndex(outputFormat) else: GUI.formatBox.setCurrentIndex(profile['DefaultFormat']) - GUI.qualityBox.setEnabled(profile['PVOptions']) + if not GUI.webtoonBox.isChecked(): + GUI.qualityBox.setEnabled(profile['PVOptions']) if str(GUI.formatBox.currentText()) == 'MOBI/AZW3': GUI.outputSplit.setEnabled(True) else: @@ -1002,6 +1018,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow): GUI.gammaSlider.valueChanged.connect(self.changeGamma) GUI.gammaBox.stateChanged.connect(self.togglegammaBox) GUI.webtoonBox.stateChanged.connect(self.togglewebtoonBox) + GUI.qualityBox.stateChanged.connect(self.togglequalityBox) GUI.deviceBox.activated.connect(self.changeDevice) GUI.formatBox.activated.connect(self.changeFormat) MW.progressBarTick.connect(self.updateProgressbar) diff --git a/kindlecomicconverter/KCC_ui.py b/kindlecomicconverter/KCC_ui.py index 71689ab..b23c981 100644 --- a/kindlecomicconverter/KCC_ui.py +++ b/kindlecomicconverter/KCC_ui.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'gui\KCC.ui' # -# Created by: PyQt5 UI code generator 5.6 +# Created by: PyQt5 UI code generator 5.8.1 # # WARNING! All changes made in this file will be lost! @@ -81,6 +81,7 @@ class Ui_mainWindow(object): self.rotateBox.setObjectName("rotateBox") self.gridLayout_2.addWidget(self.rotateBox, 0, 1, 1, 1) self.qualityBox = QtWidgets.QCheckBox(self.optionWidget) + self.qualityBox.setTristate(True) self.qualityBox.setObjectName("qualityBox") self.gridLayout_2.addWidget(self.qualityBox, 0, 2, 1, 1) self.webtoonBox = QtWidgets.QCheckBox(self.optionWidget) @@ -241,8 +242,8 @@ class Ui_mainWindow(object): self.mangaBox.setText(_translate("mainWindow", "Manga mode")) self.rotateBox.setToolTip(_translate("mainWindow", "<html><head/><body><p><span style=\" font-weight:600; text-decoration: underline;\">Unchecked - Split<br/></span>Double page spreads will be cut into two separate pages.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Indeterminate - Rotate and split<br/></span>Double page spreads will be displayed twice. First rotated and then split. </p><p><span style=\" font-weight:600; text-decoration: underline;\">Checked - Rotate<br/></span>Double page spreads will be rotated.</p></body></html>")) self.rotateBox.setText(_translate("mainWindow", "Spread splitter")) - self.qualityBox.setToolTip(_translate("mainWindow", "<html><head/><body><p style=\'white-space:pre\'><span style=\" font-weight:600; text-decoration: underline;\">Unchecked - 4 panels<br/></span>Zoom each corner separately.</p><p style=\'white-space:pre\'><span style=\" font-weight:600; text-decoration: underline;\">Checked - 2 panels<br/></span>Zoom only the top and bottom of the page.</p></body></html>")) - self.qualityBox.setText(_translate("mainWindow", "Panel View 4/2")) + self.qualityBox.setToolTip(_translate("mainWindow", "<html><head/><body><p style=\'white-space:pre\'><span style=\" font-weight:600; text-decoration: underline;\">Unchecked - 4 panels<br/></span>Zoom each corner separately.</p><p style=\'white-space:pre\'><span style=\" font-weight:600; text-decoration: underline;\">Indeterminate - 2 panels<br/></span>Zoom only the top and bottom of the page.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Checked - 4 high quality panels<br/></span>Zoom each corner separately. Try to increase the quality of magnification. Check wiki for more details.</p></body></html>")) + self.qualityBox.setText(_translate("mainWindow", "Panel View 4/2/HQ")) self.webtoonBox.setToolTip(_translate("mainWindow", "<html><head/><body><p style=\'white-space:pre\'>Enable special parsing mode for Korean Webtoons.</p></body></html>")) self.webtoonBox.setText(_translate("mainWindow", "Webtoon mode")) self.upscaleBox.setToolTip(_translate("mainWindow", "<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>")) diff --git a/kindlecomicconverter/comic2ebook.py b/kindlecomicconverter/comic2ebook.py index f2d0fc6..1bffcc4 100755 --- a/kindlecomicconverter/comic2ebook.py +++ b/kindlecomicconverter/comic2ebook.py @@ -103,6 +103,10 @@ def buildHTML(path, imgfile, imgfilepath): os.makedirs(htmlpath) htmlfile = os.path.join(htmlpath, filename[0] + '.xhtml') imgsize = Image.open(os.path.join(head, "Images", postfix, imgfile)).size + if options.hq: + imgsizeframe = deviceres + else: + imgsizeframe = imgsize f = open(htmlfile, "w", encoding='UTF-8') f.writelines(["<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "<!DOCTYPE html>\n", @@ -111,17 +115,20 @@ def buildHTML(path, imgfile, imgfilepath): "<title>", escape(filename[0]), "</title>\n", "<link href=\"", "../" * (backref - 1), "style.css\" type=\"text/css\" rel=\"stylesheet\"/>\n", "<meta name=\"viewport\" " - "content=\"width=" + str(deviceres[0]) + ", height=" + str(deviceres[1]) + "\"/>\n" + "content=\"width=" + str(imgsize[0]) + ", height=" + str(imgsize[1]) + "\"/>\n" "</head>\n", "<body style=\"" + additionalStyle + "\">\n", "<div style=\"text-align:center;top:" + getTopMargin(deviceres, imgsize) + "%;\">\n", - "<img width=\"" + str(imgsize[0]) + "\" height=\"" + str(imgsize[1]) + "\" ", + "<img width=\"" + str(imgsizeframe[0]) + "\" height=\"" + str(imgsizeframe[1]) + "\" ", "src=\"", "../" * backref, "Images/", postfix, imgfile, "\"/>\n</div>\n"]) if options.iskindle and options.panelview: if options.autoscale: size = (getPanelViewResolution(imgsize, deviceres)) else: - size = (int(imgsize[0] * 1.5), int(imgsize[1] * 1.5)) + if options.hq: + size = imgsize + else: + size = (int(imgsize[0] * 1.5), int(imgsize[1] * 1.5)) if size[0] - deviceres[0] < deviceres[0] * 0.01: noHorizontalPV = True else: @@ -884,6 +891,8 @@ def makeParser(): " KoA, KoAHD, KoAH2O, KoAO) [Default=KV]") mainOptions.add_option("-m", "--manga-style", action="store_true", dest="righttoleft", default=False, help="Manga style (right-to-left reading and splitting)") + mainOptions.add_option("-q", "--hq", action="store_true", dest="hq", default=False, + help="Try to increase the quality of magnification") mainOptions.add_option("-2", "--two-panel", action="store_true", dest="autoscale", default=False, help="Display two not four panels in Panel View mode") mainOptions.add_option("-w", "--webtoon", action="store_true", dest="webtoon", default=False, @@ -960,16 +969,20 @@ def checkOptions(): # Older Kindle models don't support Panel View. if options.profile == 'K1' or options.profile == 'K2' or options.profile == 'KDX': options.panelview = False + options.hq = False # Webtoon mode mandatory options if options.webtoon: options.panelview = False options.righttoleft = False options.upscale = True + options.hq = False # Disable all Kindle features for other e-readers if options.profile == 'OTHER': options.panelview = False + options.hq = False if 'Ko' in options.profile: options.panelview = False + options.hq = False # CBZ files on Kindle DX/DXG support higher resolution if options.profile == 'KDX' and options.format == 'CBZ': options.customheight = 1200 diff --git a/kindlecomicconverter/image.py b/kindlecomicconverter/image.py index 5035a9e..5538d88 100755 --- a/kindlecomicconverter/image.py +++ b/kindlecomicconverter/image.py @@ -209,6 +209,8 @@ class ComicPage: def __init__(self, options, mode, path, image, color, fill): self.opt = options _, self.size, self.palette, self.gamma = self.opt.profileData + if self.opt.hq: + self.size = (int(self.size[0] * 1.5), int(self.size[1] * 1.5)) self.image = image self.color = color self.fill = fill |