diff options
-rw-r--r-- | KCC-OSX.ui | 24 | ||||
-rw-r--r-- | KCC.ui | 24 | ||||
-rw-r--r-- | README.md | 6 | ||||
-rw-r--r-- | kcc/KCC_gui.py | 8 | ||||
-rw-r--r-- | kcc/KCC_ui.py | 30 | ||||
-rw-r--r-- | kcc/KCC_ui_osx.py | 32 | ||||
-rwxr-xr-x | kcc/comic2ebook.py | 68 | ||||
-rwxr-xr-x | kcc/image.py | 27 |
8 files changed, 140 insertions, 79 deletions
diff --git a/KCC-OSX.ui b/KCC-OSX.ui index d169ae0..9f95c68 100644 --- a/KCC-OSX.ui +++ b/KCC-OSX.ui @@ -88,7 +88,7 @@ <enum>Qt::NoFocus</enum> </property> <property name="toolTip"> - <string><html><head/><body><p>Enable image upscaling.</p><p>Aspect ratio will be preserved.</p></body></html></string> + <string><html><head/><body><p>Enable image upscaling.<br/>Aspect ratio will be preserved.</p></body></html></string> </property> <property name="text"> <string>Upscale images</string> @@ -106,7 +106,7 @@ <enum>Qt::NoFocus</enum> </property> <property name="toolTip"> - <string><html><head/><body><p>Enable image stretching.</p><p>Aspect ratio will be not preserved.</p></body></html></string> + <string><html><head/><body><p>Enable image stretching.<br/>Aspect ratio will be not preserved.</p></body></html></string> </property> <property name="text"> <string>Stretch images</string> @@ -124,7 +124,7 @@ <enum>Qt::NoFocus</enum> </property> <property name="toolTip"> - <string><html><head/><body><p>Create PNG files instead JPEG.</p><p><span style=" font-weight:600;">Only for non-Kindle devices!</span></p></body></html></string> + <string><html><head/><body><p>Create PNG files instead JPEG.<br/><span style=" font-weight:600;">Only for non-Kindle devices!</span></p></body></html></string> </property> <property name="text"> <string>PNG output</string> @@ -354,7 +354,7 @@ <bool>true</bool> </property> </widget> - <widget class="QCheckBox" name="HQPVBox"> + <widget class="QCheckBox" name="QualityBox"> <property name="geometry"> <rect> <x>282</x> @@ -372,12 +372,18 @@ <enum>Qt::NoFocus</enum> </property> <property name="toolTip"> - <string><html><head/><body><p>Enable high quality zoom.</p><p>Enabling it will <span style=" font-weight:600;">highly</span> increase size of output file and <span style=" font-weight:600;">slightly</span> reduce sharpness of not zoomed images.</p></body></html></string> + <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600; text-decoration: underline;">Unchecked - Normal quality mode<br /></span><span style=" font-style:italic;">Use it when Panel View support is not needed.</span><span style=" font-weight:600; text-decoration: underline;"><br /></span>- Maximum quality when zoom is not enabled.<br />- Poor quality when zoom is enabled.<br />- Lowest file size.</p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600; text-decoration: underline;">Indeterminate - High quality mode<br /></span><span style=" font-style:italic;">Not zoomed image </span><span style=" font-weight:600; font-style:italic;">might </span><span style=" font-style:italic;">be </span><span style=" font-style:italic;">a little blurry.</span><span style=" font-weight:600; text-decoration: underline;"><br /></span>- Medium/High quality when zoom is not enabled.<br />- Maximum quality when zoom is enabled.</p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600; text-decoration: underline;">Checked - Ultra quality mode<br /></span><span style=" font-style:italic;">Maximum possible quality.</span><span style=" font-weight:600; text-decoration: underline;"><br /></span>- Maximum quality when zoom is not enabled.<br />- Maximum quality when zoom is enabled.<br />- Very high file size.</p></body></html></string> </property> <property name="text"> - <string>HQ Panel View</string> + <string>High/Ultra quality</string> </property> - <property name="checked"> + <property name="tristate"> <bool>true</bool> </property> </widget> @@ -399,7 +405,7 @@ <enum>Qt::NoFocus</enum> </property> <property name="toolTip"> - <string><html><head/><body><p>Disable page spliting.</p><p>They will be rotated instead.</p></body></html></string> + <string><html><head/><body><p>Disable page spliting.<br/>They will be rotated instead.</p></body></html></string> </property> <property name="text"> <string>Horizontal mode</string> @@ -407,7 +413,7 @@ </widget> <zorder>RotateBox</zorder> <zorder>MangaBox</zorder> - <zorder>HQPVBox</zorder> + <zorder>QualityBox</zorder> </widget> <widget class="QListWidget" name="JobList"> <property name="geometry"> diff --git a/KCC.ui b/KCC.ui index 2fc2354..664cad8 100644 --- a/KCC.ui +++ b/KCC.ui @@ -78,7 +78,7 @@ <enum>Qt::NoFocus</enum> </property> <property name="toolTip"> - <string><html><head/><body><p>Enable image upscaling.</p><p>Aspect ratio will be preserved.</p></body></html></string> + <string><html><head/><body><p>Enable image upscaling.<br/>Aspect ratio will be preserved.</p></body></html></string> </property> <property name="text"> <string>Upscale images</string> @@ -91,7 +91,7 @@ <enum>Qt::NoFocus</enum> </property> <property name="toolTip"> - <string><html><head/><body><p>Enable image stretching.</p><p>Aspect ratio will be not preserved.</p></body></html></string> + <string><html><head/><body><p>Enable image stretching.<br/>Aspect ratio will be not preserved.</p></body></html></string> </property> <property name="text"> <string>Stretch images</string> @@ -104,7 +104,7 @@ <enum>Qt::NoFocus</enum> </property> <property name="toolTip"> - <string><html><head/><body><p>Create PNG files instead JPEG.</p><p><span style=" font-weight:600;">Only for non-Kindle devices!</span></p></body></html></string> + <string><html><head/><body><p>Create PNG files instead JPEG.<br/><span style=" font-weight:600;">Only for non-Kindle devices!</span></p></body></html></string> </property> <property name="text"> <string>PNG output</string> @@ -319,7 +319,7 @@ <bool>true</bool> </property> </widget> - <widget class="QCheckBox" name="HQPVBox"> + <widget class="QCheckBox" name="QualityBox"> <property name="geometry"> <rect> <x>282</x> @@ -332,12 +332,18 @@ <enum>Qt::NoFocus</enum> </property> <property name="toolTip"> - <string><html><head/><body><p>Enable high quality zoom.</p><p>Enabling it will <span style=" font-weight:600;">highly</span> increase size of output file and <span style=" font-weight:600;">slightly</span> reduce sharpness of not zoomed images.</p></body></html></string> + <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600; text-decoration: underline;">Unchecked - Normal quality mode<br /></span><span style=" font-style:italic;">Use it when Panel View support is not needed.</span><span style=" font-weight:600; text-decoration: underline;"><br /></span>- Maximum quality when zoom is not enabled.<br />- Poor quality when zoom is enabled.<br />- Lowest file size.</p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600; text-decoration: underline;">Indeterminate - High quality mode<br /></span><span style=" font-style:italic;">Not zoomed image </span><span style=" font-weight:600; font-style:italic;">might </span><span style=" font-style:italic;">be </span><span style=" font-style:italic;">a little blurry.</span><span style=" font-weight:600; text-decoration: underline;"><br /></span>- Medium/High quality when zoom is not enabled.<br />- Maximum quality when zoom is enabled.</p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600; text-decoration: underline;">Checked - Ultra quality mode<br /></span><span style=" font-style:italic;">Maximum possible quality.</span><span style=" font-weight:600; text-decoration: underline;"><br /></span>- Maximum quality when zoom is not enabled.<br />- Maximum quality when zoom is enabled.<br />- Very high file size.</p></body></html></string> </property> <property name="text"> - <string>HQ Panel View</string> + <string>High/Ultra quality</string> </property> - <property name="checked"> + <property name="tristate"> <bool>true</bool> </property> </widget> @@ -354,7 +360,7 @@ <enum>Qt::NoFocus</enum> </property> <property name="toolTip"> - <string><html><head/><body><p>Disable page spliting.</p><p>They will be rotated instead.</p></body></html></string> + <string><html><head/><body><p>Disable page spliting.<br/>They will be rotated instead.</p></body></html></string> </property> <property name="text"> <string>Horizontal mode</string> @@ -362,7 +368,7 @@ </widget> <zorder>RotateBox</zorder> <zorder>MangaBox</zorder> - <zorder>HQPVBox</zorder> + <zorder>QualityBox</zorder> </widget> <widget class="QListWidget" name="JobList"> <property name="geometry"> diff --git a/README.md b/README.md index a6ab1df..aad8ec0 100644 --- a/README.md +++ b/README.md @@ -49,8 +49,7 @@ In the meanwhile you can download [version 2.9](http://kcc.vulturis.eu/OSX/Kindl ### Important tips: * Use high quality source files. **This little detail have a major impact on the final result.** -* Disabling **HQ Panel View** might improve sharpness of image when it is not zoomed. -* Disabling **HQ Panel View** will highly decrease size of output file. +* Read tooltip of _High/Ultra quality_ option. There are many important informations there. * The first image found will be set as the comic's cover. * All files/directories will be added to EPUB in alphabetical order. * Output MOBI file should be uploaded via USB. Other methods (e.g. via Calibre) might corrupt it. @@ -74,8 +73,8 @@ Options: -t TITLE, --title=TITLE Comic title [Default=filename] -m, --manga-style Manga style (Right-to-left reading and splitting) [Default=False] + --quality=QUALITY Output quality. 0 - Normal 1 - High 2 - Ultra [Default=0] -c, --cbz-output Outputs a CBZ archive and does not generate EPUB - --nopanelviewhq Disable high quality Panel View [Default=False] --noprocessing Do not apply image preprocessing (Page splitting and optimizations) [Default=True] --forcepng Create PNG files instead JPEG (For non-Kindle devices) [Default=False] --gamma=GAMMA Apply gamma correction to linearize the image [Default=Auto] @@ -209,6 +208,7 @@ The app relies and includes the following scripts/binaries: ####3.0: * New QT GUI * Merge with AWKCC +* Added ultra quality mode * Added support for custom width/height * Added option to disable color conversion diff --git a/kcc/KCC_gui.py b/kcc/KCC_gui.py index cbbbd66..03758de 100644 --- a/kcc/KCC_gui.py +++ b/kcc/KCC_gui.py @@ -93,8 +93,10 @@ class WorkerThread(QtCore.QThread): argv.append("--manga-style") if GUI.RotateBox.isChecked(): argv.append("--rotate") - if not GUI.HQPVBox.isChecked(): - argv.append("--nopanelviewhq") + if GUI.QualityBox.checkState() == 1: + argv.append("--quality=1") + elif GUI.QualityBox.checkState() == 2: + argv.append("--quality=2") if GUI.ProcessingBox.isChecked(): argv.append("--noprocessing") if GUI.UpscaleBox.isChecked() and not GUI.StretchBox.isChecked(): @@ -135,7 +137,7 @@ class WorkerThread(QtCore.QThread): except Exception as err: self.errors = True type_, value_, traceback_ = sys.exc_info() - self.emit(QtCore.SIGNAL("showDialog"), "Error on file %s:\n%s\nTraceback:\n%s" + self.emit(QtCore.SIGNAL("showDialog"), "Error during convertion %s:\n\n%s\n\nTraceback:\n%s" % (jobargv[-1], str(err), traceback.format_tb(traceback_))) self.emit(QtCore.SIGNAL("addMessage"), 'KCC failed to create EPUB!', 'error') if not self.errors: diff --git a/kcc/KCC_ui.py b/kcc/KCC_ui.py index ecf2e1d..1e5f144 100644 --- a/kcc/KCC_ui.py +++ b/kcc/KCC_ui.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'KCC.ui' # -# Created: Sun Jun 16 23:04:29 2013 +# Created: Tue Jun 18 22:41:54 2013 # by: PyQt4 UI code generator 4.10.1 # # WARNING! All changes made in this file will be lost! @@ -139,11 +139,11 @@ class Ui_KCC(object): self.MangaBox.setFocusPolicy(QtCore.Qt.NoFocus) self.MangaBox.setChecked(True) self.MangaBox.setObjectName(_fromUtf8("MangaBox")) - self.HQPVBox = QtGui.QCheckBox(self.OptionsBasic) - self.HQPVBox.setGeometry(QtCore.QRect(282, 10, 130, 18)) - self.HQPVBox.setFocusPolicy(QtCore.Qt.NoFocus) - self.HQPVBox.setChecked(True) - self.HQPVBox.setObjectName(_fromUtf8("HQPVBox")) + self.QualityBox = QtGui.QCheckBox(self.OptionsBasic) + self.QualityBox.setGeometry(QtCore.QRect(282, 10, 130, 18)) + self.QualityBox.setFocusPolicy(QtCore.Qt.NoFocus) + self.QualityBox.setTristate(True) + self.QualityBox.setObjectName(_fromUtf8("QualityBox")) self.RotateBox = QtGui.QCheckBox(self.OptionsBasic) self.RotateBox.setGeometry(QtCore.QRect(145, 10, 130, 18)) self.RotateBox.setFocusPolicy(QtCore.Qt.NoFocus) @@ -270,11 +270,11 @@ class Ui_KCC(object): KCC.setWindowTitle(_translate("KCC", "Kindle Comic Converter", None)) self.ProcessingBox.setToolTip(_translate("KCC", "Disable image optimizations.", None)) self.ProcessingBox.setText(_translate("KCC", "No optimisation", None)) - self.UpscaleBox.setToolTip(_translate("KCC", "<html><head/><body><p>Enable image upscaling.</p><p>Aspect ratio will be preserved.</p></body></html>", None)) + self.UpscaleBox.setToolTip(_translate("KCC", "<html><head/><body><p>Enable image upscaling.<br/>Aspect ratio will be preserved.</p></body></html>", None)) self.UpscaleBox.setText(_translate("KCC", "Upscale images", None)) - self.StretchBox.setToolTip(_translate("KCC", "<html><head/><body><p>Enable image stretching.</p><p>Aspect ratio will be not preserved.</p></body></html>", None)) + self.StretchBox.setToolTip(_translate("KCC", "<html><head/><body><p>Enable image stretching.<br/>Aspect ratio will be not preserved.</p></body></html>", None)) self.StretchBox.setText(_translate("KCC", "Stretch images", None)) - self.NoDitheringBox.setToolTip(_translate("KCC", "<html><head/><body><p>Create PNG files instead JPEG.</p><p><span style=\" font-weight:600;\">Only for non-Kindle devices!</span></p></body></html>", 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)) self.BorderBox.setText(_translate("KCC", "Black borders", None)) @@ -288,9 +288,15 @@ class Ui_KCC(object): self.ClearButton.setText(_translate("KCC", "Clear list", None)) self.MangaBox.setToolTip(_translate("KCC", "Enable right-to-left reading.", None)) self.MangaBox.setText(_translate("KCC", "Manga mode", None)) - self.HQPVBox.setToolTip(_translate("KCC", "<html><head/><body><p>Enable high quality zoom.</p><p>Enabling it will <span style=\" font-weight:600;\">highly</span> increase size of output file and <span style=\" font-weight:600;\">slightly</span> reduce sharpness of not zoomed images.</p></body></html>", None)) - self.HQPVBox.setText(_translate("KCC", "HQ Panel View", None)) - self.RotateBox.setToolTip(_translate("KCC", "<html><head/><body><p>Disable page spliting.</p><p>They will be rotated instead.</p></body></html>", None)) + self.QualityBox.setToolTip(_translate("KCC", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" +"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" +"p, li { white-space: pre-wrap; }\n" +"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8pt; font-weight:400; font-style:normal;\">\n" +"<p style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600; text-decoration: underline;\">Unchecked - Normal quality mode<br /></span><span style=\" font-style:italic;\">Use it when Panel View support is not needed.</span><span style=\" font-weight:600; text-decoration: underline;\"><br /></span>- Maximum quality when zoom is not enabled.<br />- Poor quality when zoom is enabled.<br />- Lowest file size.</p>\n" +"<p style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600; text-decoration: underline;\">Indeterminate - High quality mode<br /></span><span style=\" font-style:italic;\">Not zoomed image </span><span style=\" font-weight:600; font-style:italic;\">might </span><span style=\" font-style:italic;\">be </span><span style=\" font-style:italic;\">a little blurry.</span><span style=\" font-weight:600; text-decoration: underline;\"><br /></span>- Medium/High quality when zoom is not enabled.<br />- Maximum quality when zoom is enabled.</p>\n" +"<p style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600; text-decoration: underline;\">Checked - Ultra quality mode<br /></span><span style=\" font-style:italic;\">Maximum possible quality.</span><span style=\" font-weight:600; text-decoration: underline;\"><br /></span>- Maximum quality when zoom is not enabled.<br />- Maximum quality when zoom is enabled.<br />- Very high file size.</p></body></html>", None)) + self.QualityBox.setText(_translate("KCC", "High/Ultra quality", None)) + self.RotateBox.setToolTip(_translate("KCC", "<html><head/><body><p>Disable page spliting.<br/>They will be rotated instead.</p></body></html>", None)) self.RotateBox.setText(_translate("KCC", "Horizontal mode", None)) self.BasicModeButton.setText(_translate("KCC", "Basic", None)) self.AdvModeButton.setText(_translate("KCC", "Advanced", None)) diff --git a/kcc/KCC_ui_osx.py b/kcc/KCC_ui_osx.py index 45ca8cf..50832e4 100644 --- a/kcc/KCC_ui_osx.py +++ b/kcc/KCC_ui_osx.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'KCC-OSX.ui' # -# Created: Sun Jun 16 23:28:28 2013 +# Created: Tue Jun 18 22:42:06 2013 # by: PyQt4 UI code generator 4.10.1 # # WARNING! All changes made in this file will be lost! @@ -160,14 +160,14 @@ class Ui_KCC(object): self.MangaBox.setFocusPolicy(QtCore.Qt.NoFocus) self.MangaBox.setChecked(True) self.MangaBox.setObjectName(_fromUtf8("MangaBox")) - self.HQPVBox = QtGui.QCheckBox(self.OptionsBasic) - self.HQPVBox.setGeometry(QtCore.QRect(282, 10, 130, 18)) + self.QualityBox = QtGui.QCheckBox(self.OptionsBasic) + self.QualityBox.setGeometry(QtCore.QRect(282, 10, 130, 18)) font = QtGui.QFont() font.setPointSize(11) - self.HQPVBox.setFont(font) - self.HQPVBox.setFocusPolicy(QtCore.Qt.NoFocus) - self.HQPVBox.setChecked(True) - self.HQPVBox.setObjectName(_fromUtf8("HQPVBox")) + self.QualityBox.setFont(font) + self.QualityBox.setFocusPolicy(QtCore.Qt.NoFocus) + self.QualityBox.setTristate(True) + self.QualityBox.setObjectName(_fromUtf8("QualityBox")) self.RotateBox = QtGui.QCheckBox(self.OptionsBasic) self.RotateBox.setGeometry(QtCore.QRect(145, 10, 130, 18)) font = QtGui.QFont() @@ -329,11 +329,11 @@ class Ui_KCC(object): KCC.setWindowTitle(_translate("KCC", "Kindle Comic Converter", None)) self.ProcessingBox.setToolTip(_translate("KCC", "Disable image optimizations.", None)) self.ProcessingBox.setText(_translate("KCC", "No optimisation", None)) - self.UpscaleBox.setToolTip(_translate("KCC", "<html><head/><body><p>Enable image upscaling.</p><p>Aspect ratio will be preserved.</p></body></html>", None)) + self.UpscaleBox.setToolTip(_translate("KCC", "<html><head/><body><p>Enable image upscaling.<br/>Aspect ratio will be preserved.</p></body></html>", None)) self.UpscaleBox.setText(_translate("KCC", "Upscale images", None)) - self.StretchBox.setToolTip(_translate("KCC", "<html><head/><body><p>Enable image stretching.</p><p>Aspect ratio will be not preserved.</p></body></html>", None)) + self.StretchBox.setToolTip(_translate("KCC", "<html><head/><body><p>Enable image stretching.<br/>Aspect ratio will be not preserved.</p></body></html>", None)) self.StretchBox.setText(_translate("KCC", "Stretch images", None)) - self.NoDitheringBox.setToolTip(_translate("KCC", "<html><head/><body><p>Create PNG files instead JPEG.</p><p><span style=\" font-weight:600;\">Only for non-Kindle devices!</span></p></body></html>", 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)) self.BorderBox.setText(_translate("KCC", "Black borders", None)) @@ -347,9 +347,15 @@ class Ui_KCC(object): self.ClearButton.setText(_translate("KCC", "Clear list", None)) self.MangaBox.setToolTip(_translate("KCC", "Enable right-to-left reading.", None)) self.MangaBox.setText(_translate("KCC", "Manga mode", None)) - self.HQPVBox.setToolTip(_translate("KCC", "<html><head/><body><p>Enable high quality zoom.</p><p>Enabling it will <span style=\" font-weight:600;\">highly</span> increase size of output file and <span style=\" font-weight:600;\">slightly</span> reduce sharpness of not zoomed images.</p></body></html>", None)) - self.HQPVBox.setText(_translate("KCC", "HQ Panel View", None)) - self.RotateBox.setToolTip(_translate("KCC", "<html><head/><body><p>Disable page spliting.</p><p>They will be rotated instead.</p></body></html>", None)) + self.QualityBox.setToolTip(_translate("KCC", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" +"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" +"p, li { white-space: pre-wrap; }\n" +"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8pt; font-weight:400; font-style:normal;\">\n" +"<p style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600; text-decoration: underline;\">Unchecked - Normal quality mode<br /></span><span style=\" font-style:italic;\">Use it when Panel View support is not needed.</span><span style=\" font-weight:600; text-decoration: underline;\"><br /></span>- Maximum quality when zoom is not enabled.<br />- Poor quality when zoom is enabled.<br />- Lowest file size.</p>\n" +"<p style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600; text-decoration: underline;\">Indeterminate - High quality mode<br /></span><span style=\" font-style:italic;\">Not zoomed image </span><span style=\" font-weight:600; font-style:italic;\">might </span><span style=\" font-style:italic;\">be </span><span style=\" font-style:italic;\">a little blurry.</span><span style=\" font-weight:600; text-decoration: underline;\"><br /></span>- Medium/High quality when zoom is not enabled.<br />- Maximum quality when zoom is enabled.</p>\n" +"<p style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600; text-decoration: underline;\">Checked - Ultra quality mode<br /></span><span style=\" font-style:italic;\">Maximum possible quality.</span><span style=\" font-weight:600; text-decoration: underline;\"><br /></span>- Maximum quality when zoom is not enabled.<br />- Maximum quality when zoom is enabled.<br />- Very high file size.</p></body></html>", None)) + self.QualityBox.setText(_translate("KCC", "High/Ultra quality", None)) + self.RotateBox.setToolTip(_translate("KCC", "<html><head/><body><p>Disable page spliting.<br/>They will be rotated instead.</p></body></html>", None)) self.RotateBox.setText(_translate("KCC", "Horizontal mode", None)) self.BasicModeButton.setText(_translate("KCC", "Basic", None)) self.AdvModeButton.setText(_translate("KCC", "Advanced", None)) diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index 3fac9ce..86d9712 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -27,6 +27,7 @@ import sys import tempfile import re import stat +import string from shutil import move from shutil import copyfile from shutil import copytree @@ -47,7 +48,7 @@ def buildHTML(path, imgfile): filename = getImageFileName(imgfile) if filename is not None: # All files marked with this sufix need horizontal Panel View. - if "_rotated" in str(filename): + if "_kccrotated" in str(filename): rotate = True else: rotate = False @@ -123,18 +124,23 @@ def buildHTML(path, imgfile): "<div id=\"BoxBR\"><a class=\"app-amzn-magnify\" data-app-amzn-magnify=" "'{\"targetId\":\"BoxBR-Panel-Parent\", \"ordinal\":4}'></a></div>\n" ]) - + if options.quality == 2: + imgfilepv = string.split(imgfile, ".") + imgfilepv[0] += "_kcchq" + imgfilepv = string.join(imgfilepv, ".") + else: + imgfilepv = imgfile f.writelines(["<div id=\"BoxTL-Panel-Parent\" class=\"target-mag-parent\"><div id=\"BoxTL-Panel\" class=\"", - "target-mag\"><img src=\"", "../" * backref, "Images/", postfix, imgfile, "\" alt=\"", + "target-mag\"><img src=\"", "../" * backref, "Images/", postfix, imgfilepv, "\" alt=\"", imgfile, "\"/></div></div>\n", "<div id=\"BoxTR-Panel-Parent\" class=\"target-mag-parent\"><div id=\"BoxTR-Panel\" class=\"", - "target-mag\"><img src=\"", "../" * backref, "Images/", postfix, imgfile, "\" alt=\"", + "target-mag\"><img src=\"", "../" * backref, "Images/", postfix, imgfilepv, "\" alt=\"", imgfile, "\"/></div></div>\n", "<div id=\"BoxBL-Panel-Parent\" class=\"target-mag-parent\"><div id=\"BoxBL-Panel\" class=\"", - "target-mag\"><img src=\"", "../" * backref, "Images/", postfix, imgfile, "\" alt=\"", + "target-mag\"><img src=\"", "../" * backref, "Images/", postfix, imgfilepv, "\" alt=\"", imgfile, "\"/></div></div>\n", "<div id=\"BoxBR-Panel-Parent\" class=\"target-mag-parent\"><div id=\"BoxBR-Panel\" class=\"", - "target-mag\"><img src=\"", "../" * backref, "Images/", postfix, imgfile, "\" alt=\"", + "target-mag\"><img src=\"", "../" * backref, "Images/", postfix, imgfilepv, "\" alt=\"", imgfile, "\"/></div></div>\n" ]) f.writelines(["</div>\n</body>\n</html>"]) @@ -261,7 +267,7 @@ def buildOPF(dstdir, title, filelist, cover=None): f.write("</manifest>\n<spine toc=\"ncx\">\n") splitCountUsed = 1 for entry in reflist: - if entry.endswith("-kcca"): + if "_kcca" in str(entry): # noinspection PyRedundantParentheses if ((options.righttoleft and facing == 'left') or (not options.righttoleft and facing == 'right')) and\ options.landscapemode: @@ -271,7 +277,7 @@ def buildOPF(dstdir, title, filelist, cover=None): f.write("<itemref idref=\"page_" + entry + "\" properties=\"page-spread-" + facing1 + "\"/>\n") else: f.write("<itemref idref=\"page_" + entry + "\"/>\n") - elif entry.endswith("-kccb"): + elif "_kccb" in str(entry): if options.landscapemode: f.write("<itemref idref=\"page_" + entry + "\" properties=\"page-spread-" + facing2 + "\"/>\n") else: @@ -320,12 +326,16 @@ def getImageFileName(imgfile): return filename -def applyImgOptimization(img, isSplit, toRight, options): +def applyImgOptimization(img, isSplit, toRight, options, overrideQuality=5): img.cropWhiteSpace(10.0) if options.cutpagenumbers: img.cutPageNumber() - img.resizeImage(options.upscale, options.stretch, options.black_borders, isSplit, toRight, options.landscapemode, - options.nopanelviewhq) + if overrideQuality != 5: + img.resizeImage(options.upscale, options.stretch, options.black_borders, isSplit, toRight, + options.landscapemode, overrideQuality) + else: + img.resizeImage(options.upscale, options.stretch, options.black_borders, isSplit, toRight, + options.landscapemode, options.quality) img.optimizeImage(options.gamma) if options.forcepng: img.quantizeImage() @@ -390,10 +400,14 @@ def fileImgProcess(work): print ".", fileImgProcess.queue.put(".") img = image.ComicPage(os.path.join(dirpath, afile), options.profileData) + if options.quality == 2: + wipe = False + else: + wipe = True if options.nosplitrotate: split = None else: - split = img.splitPage(dirpath, options.righttoleft, options.rotate) + split = img.splitPage(dirpath, options.righttoleft, options.rotate, wipe) if split is not None and split is not "R": if options.verbose: print "Splitted " + afile @@ -406,13 +420,25 @@ def fileImgProcess(work): output = pagenumber img0 = image.ComicPage(split[0], options.profileData) applyImgOptimization(img0, True, toRight1, options) - img0.saveToDir(dirpath, options.forcepng, options.forcecolor) + img0.saveToDir(dirpath, options.forcepng, options.forcecolor, wipe) img1 = image.ComicPage(split[1], options.profileData) applyImgOptimization(img1, True, toRight2, options) - img1.saveToDir(dirpath, options.forcepng, options.forcecolor) + img1.saveToDir(dirpath, options.forcepng, options.forcecolor, wipe) + if options.quality == 2: + split2 = img.splitPage(dirpath, options.righttoleft, options.rotate, True) + img3 = image.ComicPage(split2[0], options.profileData) + applyImgOptimization(img3, True, toRight1, options, 0) + img3.saveToDir(dirpath, options.forcepng, options.forcecolor, True, "LQ") + img4 = image.ComicPage(split2[1], options.profileData) + applyImgOptimization(img4, True, toRight2, options, 0) + img4.saveToDir(dirpath, options.forcepng, options.forcecolor, True, "LQ") else: applyImgOptimization(img, False, False, options) - img.saveToDir(dirpath, options.forcepng, options.forcecolor, split) + img.saveToDir(dirpath, options.forcepng, options.forcecolor, wipe, split) + if options.quality == 2: + img2 = image.ComicPage(os.path.join(dirpath, afile), options.profileData) + applyImgOptimization(img2, False, False, options, 0) + img2.saveToDir(dirpath, options.forcepng, options.forcecolor, True, str(split) + "LQ") return output @@ -548,7 +574,7 @@ def genEpubStruct(path): chapter = False for afile in filenames: filename = getImageFileName(afile) - if filename is not None: + if filename is not None and not "_kcchq" in filename[0]: filelist.append(buildHTML(dirpath, afile)) if not chapter: chapterlist.append((dirpath.replace('Images', 'Text'), filelist[-1][1])) @@ -663,10 +689,10 @@ def main(argv=None, qtGUI=None): help="Comic title [Default=filename]") parser.add_option("-m", "--manga-style", action="store_true", dest="righttoleft", default=False, help="Manga style (Right-to-left reading and splitting) [Default=False]") + parser.add_option("--quality", type="int", dest="quality", default="0", + help="Output quality. 0 - Normal 1 - High 2 - Ultra [Default=0]") parser.add_option("-c", "--cbz-output", action="store_true", dest="cbzoutput", default=False, help="Outputs a CBZ archive and does not generate EPUB") - parser.add_option("--nopanelviewhq", action="store_true", dest="nopanelviewhq", default=False, - help="Disable high quality Panel View [Default=False]") parser.add_option("--noprocessing", action="store_false", dest="imgproc", default=True, help="Do not apply image preprocessing (Page splitting and optimizations) [Default=True]") parser.add_option("--forcepng", action="store_true", dest="forcepng", default=False, @@ -761,9 +787,11 @@ def checkOptions(): else: options.landscapemode = False # Older Kindle don't support Virtual Panel View. We providing them configuration that will fake that feature. - if options.profile == 'K3' or options.profile == 'K4NT': + # Ultra quality mode require Real Panel View. Landscape mode don't work correcly without Virtual Panel View. + if options.profile == 'K3' or options.profile == 'K4NT' or options.quality == 2: # Real Panel View options.panelview = True + options.landscapemode = False else: # Virtual Panel View options.panelview = False @@ -771,7 +799,7 @@ def checkOptions(): # Kindle Fire family have very high resolution. Bigger images are not needed. if options.profile == 'K1' or options.profile == 'K2' or options.profile == 'KDX' or options.profile == 'KDXG'\ or options.profile == 'KF' or options.profile == 'KFHD' or options.profile == 'KFHD8': - options.nopanelviewhq = True + options.quality = 0 # Disabling grayscale conversion for Kindle Fire family. # Forcing JPEG output. For now code can't provide color PNG files. if options.profile == 'KF' or options.profile == 'KFHD' or options.profile == 'KFHD8' or options.forcecolor: diff --git a/kcc/image.py b/kcc/image.py index 3b9969c..0b44d4a 100755 --- a/kcc/image.py +++ b/kcc/image.py @@ -130,17 +130,23 @@ class ComicPage: self.image = Image.open(source) self.image = self.image.convert('RGB') - def saveToDir(self, targetdir, forcepng, color, sufix=None): + def saveToDir(self, targetdir, forcepng, color, wipe, sufix=None): filename = os.path.basename(self.origFileName) try: if not color: self.image = self.image.convert('L') # convert to grayscale - # Sufix is used to recognise which files need horizontal Panel View. if sufix == "R": - sufix = "_rotated" + sufix = "_kccrotated" + #elif sufix == "NoneLQ": + #sufix = "" + elif sufix == "RLQ": + sufix = "_kccrotated" else: sufix = "" - os.remove(os.path.join(targetdir, filename)) + if wipe: + os.remove(os.path.join(targetdir, filename)) + else: + sufix += "_kcchq" if forcepng: self.image.save(os.path.join(targetdir, os.path.splitext(filename)[0] + sufix + ".png"), "PNG") else: @@ -167,13 +173,13 @@ class ComicPage: self.image = self.image.quantize(palette=palImg) def resizeImage(self, upscale=False, stretch=False, black_borders=False, isSplit=False, toRight=False, - landscapeMode=False, noPanelViewHQ=False): + landscapeMode=False, qualityMode=0): method = Image.ANTIALIAS if black_borders: fill = 'black' else: fill = 'white' - if noPanelViewHQ: + if qualityMode == 0: size = (self.size[0], self.size[1]) else: size = (self.panelviewsize[0], self.panelviewsize[1]) @@ -210,7 +216,7 @@ class ComicPage: self.image = ImageOps.fit(self.image, size, method=method, centering=(0.5, 0.5)) return self.image - def splitPage(self, targetdir, righttoleft=False, rotate=False): + def splitPage(self, targetdir, righttoleft=False, rotate=False, wipe=False): width, height = self.image.size dstwidth, dstheight = self.size #print "Image is %d x %d" % (width,height) @@ -229,8 +235,8 @@ class ComicPage: leftbox = (0, 0, width, height / 2) rightbox = (0, height / 2, width, height) filename = os.path.splitext(os.path.basename(self.origFileName)) - fileone = targetdir + '/' + filename[0] + '-kcca' + filename[1] - filetwo = targetdir + '/' + filename[0] + '-kccb' + filename[1] + fileone = targetdir + '/' + filename[0] + '_kcca' + filename[1] + filetwo = targetdir + '/' + filename[0] + '_kccb' + filename[1] try: if righttoleft: pageone = self.image.crop(rightbox) @@ -240,7 +246,8 @@ class ComicPage: pagetwo = self.image.crop(rightbox) pageone.save(fileone) pagetwo.save(filetwo) - os.remove(self.origFileName) + if wipe: + os.remove(self.origFileName) except IOError as e: raise RuntimeError('Cannot write image in directory %s: %s' % (targetdir, e)) return fileone, filetwo |