Merge branch 'new-gui' of github.com:ciromattia/kcc into new-gui

This commit is contained in:
Ciro Mattia Gonano
2013-06-19 10:25:04 +02:00
8 changed files with 170 additions and 95 deletions
+15 -9
View File
@@ -88,7 +88,7 @@
<enum>Qt::NoFocus</enum> <enum>Qt::NoFocus</enum>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enable image upscaling.&lt;/p&gt;&lt;p&gt;Aspect ratio will be preserved.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enable image upscaling.&lt;br/&gt;Aspect ratio will be preserved.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Upscale images</string> <string>Upscale images</string>
@@ -106,7 +106,7 @@
<enum>Qt::NoFocus</enum> <enum>Qt::NoFocus</enum>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enable image stretching.&lt;/p&gt;&lt;p&gt;Aspect ratio will be not preserved.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enable image stretching.&lt;br/&gt;Aspect ratio will be not preserved.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Stretch images</string> <string>Stretch images</string>
@@ -124,7 +124,7 @@
<enum>Qt::NoFocus</enum> <enum>Qt::NoFocus</enum>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Create PNG files instead JPEG.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Only for non-Kindle devices!&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Create PNG files instead JPEG.&lt;br/&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Only for non-Kindle devices!&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>PNG output</string> <string>PNG output</string>
@@ -354,7 +354,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
<widget class="QCheckBox" name="HQPVBox"> <widget class="QCheckBox" name="QualityBox">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>282</x> <x>282</x>
@@ -372,12 +372,18 @@
<enum>Qt::NoFocus</enum> <enum>Qt::NoFocus</enum>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enable high quality zoom.&lt;/p&gt;&lt;p&gt;Enabling it will &lt;span style=&quot; font-weight:600;&quot;&gt;highly&lt;/span&gt; increase size of output file and &lt;span style=&quot; font-weight:600;&quot;&gt;slightly&lt;/span&gt; reduce sharpness of not zoomed images.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600; text-decoration: underline;&quot;&gt;Unchecked - Normal quality mode&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Use it when Panel View support is not needed.&lt;/span&gt;&lt;span style=&quot; font-weight:600; text-decoration: underline;&quot;&gt;&lt;br /&gt;&lt;/span&gt;- Maximum quality when zoom is not enabled.&lt;br /&gt;- Poor quality when zoom is enabled.&lt;br /&gt;- Lowest file size.&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600; text-decoration: underline;&quot;&gt;Indeterminate - High quality mode&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Not zoomed image &lt;/span&gt;&lt;span style=&quot; font-weight:600; font-style:italic;&quot;&gt;might &lt;/span&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;be &lt;/span&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;a little blurry.&lt;/span&gt;&lt;span style=&quot; font-weight:600; text-decoration: underline;&quot;&gt;&lt;br /&gt;&lt;/span&gt;- Medium/High quality when zoom is not enabled.&lt;br /&gt;- Maximum quality when zoom is enabled.&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600; text-decoration: underline;&quot;&gt;Checked - Ultra quality mode&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Maximum possible quality.&lt;/span&gt;&lt;span style=&quot; font-weight:600; text-decoration: underline;&quot;&gt;&lt;br /&gt;&lt;/span&gt;- Maximum quality when zoom is not enabled.&lt;br /&gt;- Maximum quality when zoom is enabled.&lt;br /&gt;- Very high file size.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>HQ Panel View</string> <string>High/Ultra quality</string>
</property> </property>
<property name="checked"> <property name="tristate">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
@@ -399,7 +405,7 @@
<enum>Qt::NoFocus</enum> <enum>Qt::NoFocus</enum>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Disable page spliting.&lt;/p&gt;&lt;p&gt;They will be rotated instead.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Disable page spliting.&lt;br/&gt;They will be rotated instead.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Horizontal mode</string> <string>Horizontal mode</string>
@@ -407,7 +413,7 @@
</widget> </widget>
<zorder>RotateBox</zorder> <zorder>RotateBox</zorder>
<zorder>MangaBox</zorder> <zorder>MangaBox</zorder>
<zorder>HQPVBox</zorder> <zorder>QualityBox</zorder>
</widget> </widget>
<widget class="QListWidget" name="JobList"> <widget class="QListWidget" name="JobList">
<property name="geometry"> <property name="geometry">
+15 -9
View File
@@ -78,7 +78,7 @@
<enum>Qt::NoFocus</enum> <enum>Qt::NoFocus</enum>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enable image upscaling.&lt;/p&gt;&lt;p&gt;Aspect ratio will be preserved.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enable image upscaling.&lt;br/&gt;Aspect ratio will be preserved.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Upscale images</string> <string>Upscale images</string>
@@ -91,7 +91,7 @@
<enum>Qt::NoFocus</enum> <enum>Qt::NoFocus</enum>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enable image stretching.&lt;/p&gt;&lt;p&gt;Aspect ratio will be not preserved.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enable image stretching.&lt;br/&gt;Aspect ratio will be not preserved.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Stretch images</string> <string>Stretch images</string>
@@ -104,7 +104,7 @@
<enum>Qt::NoFocus</enum> <enum>Qt::NoFocus</enum>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Create PNG files instead JPEG.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Only for non-Kindle devices!&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Create PNG files instead JPEG.&lt;br/&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Only for non-Kindle devices!&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>PNG output</string> <string>PNG output</string>
@@ -319,7 +319,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
<widget class="QCheckBox" name="HQPVBox"> <widget class="QCheckBox" name="QualityBox">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>282</x> <x>282</x>
@@ -332,12 +332,18 @@
<enum>Qt::NoFocus</enum> <enum>Qt::NoFocus</enum>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enable high quality zoom.&lt;/p&gt;&lt;p&gt;Enabling it will &lt;span style=&quot; font-weight:600;&quot;&gt;highly&lt;/span&gt; increase size of output file and &lt;span style=&quot; font-weight:600;&quot;&gt;slightly&lt;/span&gt; reduce sharpness of not zoomed images.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600; text-decoration: underline;&quot;&gt;Unchecked - Normal quality mode&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Use it when Panel View support is not needed.&lt;/span&gt;&lt;span style=&quot; font-weight:600; text-decoration: underline;&quot;&gt;&lt;br /&gt;&lt;/span&gt;- Maximum quality when zoom is not enabled.&lt;br /&gt;- Poor quality when zoom is enabled.&lt;br /&gt;- Lowest file size.&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600; text-decoration: underline;&quot;&gt;Indeterminate - High quality mode&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Not zoomed image &lt;/span&gt;&lt;span style=&quot; font-weight:600; font-style:italic;&quot;&gt;might &lt;/span&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;be &lt;/span&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;a little blurry.&lt;/span&gt;&lt;span style=&quot; font-weight:600; text-decoration: underline;&quot;&gt;&lt;br /&gt;&lt;/span&gt;- Medium/High quality when zoom is not enabled.&lt;br /&gt;- Maximum quality when zoom is enabled.&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600; text-decoration: underline;&quot;&gt;Checked - Ultra quality mode&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Maximum possible quality.&lt;/span&gt;&lt;span style=&quot; font-weight:600; text-decoration: underline;&quot;&gt;&lt;br /&gt;&lt;/span&gt;- Maximum quality when zoom is not enabled.&lt;br /&gt;- Maximum quality when zoom is enabled.&lt;br /&gt;- Very high file size.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>HQ Panel View</string> <string>High/Ultra quality</string>
</property> </property>
<property name="checked"> <property name="tristate">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
@@ -354,7 +360,7 @@
<enum>Qt::NoFocus</enum> <enum>Qt::NoFocus</enum>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Disable page spliting.&lt;/p&gt;&lt;p&gt;They will be rotated instead.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Disable page spliting.&lt;br/&gt;They will be rotated instead.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Horizontal mode</string> <string>Horizontal mode</string>
@@ -362,7 +368,7 @@
</widget> </widget>
<zorder>RotateBox</zorder> <zorder>RotateBox</zorder>
<zorder>MangaBox</zorder> <zorder>MangaBox</zorder>
<zorder>HQPVBox</zorder> <zorder>QualityBox</zorder>
</widget> </widget>
<widget class="QListWidget" name="JobList"> <widget class="QListWidget" name="JobList">
<property name="geometry"> <property name="geometry">
+3 -3
View File
@@ -49,8 +49,7 @@ In the meanwhile you can download [version 2.9](http://kcc.vulturis.eu/OSX/Kindl
### Important tips: ### Important tips:
* Use high quality source files. **This little detail have a major impact on the final result.** * 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. * Read tooltip of _High/Ultra quality_ option. There are many important informations there.
* Disabling **HQ Panel View** will highly decrease size of output file.
* The first image found will be set as the comic's cover. * The first image found will be set as the comic's cover.
* All files/directories will be added to EPUB in alphabetical order. * 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. * 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 -t TITLE, --title=TITLE
Comic title [Default=filename] Comic title [Default=filename]
-m, --manga-style Manga style (Right-to-left reading and splitting) [Default=False] -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 -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] --noprocessing Do not apply image preprocessing (Page splitting and optimizations) [Default=True]
--forcepng Create PNG files instead JPEG (For non-Kindle devices) [Default=False] --forcepng Create PNG files instead JPEG (For non-Kindle devices) [Default=False]
--gamma=GAMMA Apply gamma correction to linearize the image [Default=Auto] --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: ####3.0:
* New QT GUI * New QT GUI
* Merge with AWKCC * Merge with AWKCC
* Added ultra quality mode
* Added support for custom width/height * Added support for custom width/height
* Added option to disable color conversion * Added option to disable color conversion
+11 -7
View File
@@ -93,8 +93,10 @@ class WorkerThread(QtCore.QThread):
argv.append("--manga-style") argv.append("--manga-style")
if GUI.RotateBox.isChecked(): if GUI.RotateBox.isChecked():
argv.append("--rotate") argv.append("--rotate")
if not GUI.HQPVBox.isChecked(): if GUI.QualityBox.checkState() == 1:
argv.append("--nopanelviewhq") argv.append("--quality=1")
elif GUI.QualityBox.checkState() == 2:
argv.append("--quality=2")
if GUI.ProcessingBox.isChecked(): if GUI.ProcessingBox.isChecked():
argv.append("--noprocessing") argv.append("--noprocessing")
if GUI.UpscaleBox.isChecked() and not GUI.StretchBox.isChecked(): if GUI.UpscaleBox.isChecked() and not GUI.StretchBox.isChecked():
@@ -135,10 +137,8 @@ class WorkerThread(QtCore.QThread):
except Exception as err: except Exception as err:
self.errors = True self.errors = True
type_, value_, traceback_ = sys.exc_info() type_, value_, traceback_ = sys.exc_info()
QtGui.QMessageBox.critical(MainWindow, 'KCC Error', self.emit(QtCore.SIGNAL("showDialog"), "Error during convertion %s:\n\n%s\n\nTraceback:\n%s"
"Error on file %s:\n%s\nTraceback:\n%s" % (jobargv[-1], str(err), traceback.format_tb(traceback_)))
% (jobargv[-1], str(err), traceback.format_tb(traceback_)),
QtGui.QMessageBox.Ok)
self.emit(QtCore.SIGNAL("addMessage"), 'KCC failed to create EPUB!', 'error') self.emit(QtCore.SIGNAL("addMessage"), 'KCC failed to create EPUB!', 'error')
if not self.errors: if not self.errors:
if str(GUI.FormatBox.currentText()) == 'CBZ': if str(GUI.FormatBox.currentText()) == 'CBZ':
@@ -153,7 +153,6 @@ class WorkerThread(QtCore.QThread):
retcode = call('kindlegen "' + outputPath + '"', shell=True) retcode = call('kindlegen "' + outputPath + '"', shell=True)
except: except:
continue continue
self.emit(QtCore.SIGNAL("hideProgressBar"))
if retcode == 0: if retcode == 0:
self.emit(QtCore.SIGNAL("addMessage"), 'Creating MOBI file... Done!', 'info', True) self.emit(QtCore.SIGNAL("addMessage"), 'Creating MOBI file... Done!', 'info', True)
self.emit(QtCore.SIGNAL("addMessage"), 'Removing SRCS header...', 'info') self.emit(QtCore.SIGNAL("addMessage"), 'Removing SRCS header...', 'info')
@@ -184,6 +183,7 @@ class WorkerThread(QtCore.QThread):
self.emit(QtCore.SIGNAL("addMessage"), 'Created EPUB file is too big for KindleGen!', 'error') self.emit(QtCore.SIGNAL("addMessage"), 'Created EPUB file is too big for KindleGen!', 'error')
self.emit(QtCore.SIGNAL("addMessage"), 'Limit exceeded by ' + str(excess) + self.emit(QtCore.SIGNAL("addMessage"), 'Limit exceeded by ' + str(excess) +
' MB. Try converting smaller batch.', 'error') ' MB. Try converting smaller batch.', 'error')
self.emit(QtCore.SIGNAL("hideProgressBar"))
self.parent.needClean = True self.parent.needClean = True
self.emit(QtCore.SIGNAL("addMessage"), 'All jobs completed.', 'info') self.emit(QtCore.SIGNAL("addMessage"), 'All jobs completed.', 'info')
self.emit(QtCore.SIGNAL("modeConvert"), True) self.emit(QtCore.SIGNAL("modeConvert"), True)
@@ -343,6 +343,9 @@ class Ui_KCC(object):
GUI.JobList.addItem(item) GUI.JobList.addItem(item)
GUI.JobList.scrollToBottom() GUI.JobList.scrollToBottom()
def showDialog(self, message):
QtGui.QMessageBox.critical(MainWindow, 'KCC Error', message, QtGui.QMessageBox.Ok)
def updateProgressbar(self, new=False, status=False): def updateProgressbar(self, new=False, status=False):
if new == "status": if new == "status":
pass pass
@@ -413,6 +416,7 @@ class Ui_KCC(object):
KCC.connect(self.worker, QtCore.SIGNAL("progressBarTick"), self.updateProgressbar) KCC.connect(self.worker, QtCore.SIGNAL("progressBarTick"), self.updateProgressbar)
KCC.connect(self.worker, QtCore.SIGNAL("modeConvert"), self.modeConvert) KCC.connect(self.worker, QtCore.SIGNAL("modeConvert"), self.modeConvert)
KCC.connect(self.worker, QtCore.SIGNAL("addMessage"), self.addMessage) KCC.connect(self.worker, QtCore.SIGNAL("addMessage"), self.addMessage)
KCC.connect(self.worker, QtCore.SIGNAL("showDialog"), self.showDialog)
KCC.connect(self.worker, QtCore.SIGNAL("hideProgressBar"), self.hideProgressBar) KCC.connect(self.worker, QtCore.SIGNAL("hideProgressBar"), self.hideProgressBar)
KCC.connect(self.versionCheck, QtCore.SIGNAL("addMessage"), self.addMessage) KCC.connect(self.versionCheck, QtCore.SIGNAL("addMessage"), self.addMessage)
KCC.closeEvent = self.saveSettings KCC.closeEvent = self.saveSettings
+18 -12
View File
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'KCC.ui' # 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 # by: PyQt4 UI code generator 4.10.1
# #
# WARNING! All changes made in this file will be lost! # 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.setFocusPolicy(QtCore.Qt.NoFocus)
self.MangaBox.setChecked(True) self.MangaBox.setChecked(True)
self.MangaBox.setObjectName(_fromUtf8("MangaBox")) self.MangaBox.setObjectName(_fromUtf8("MangaBox"))
self.HQPVBox = QtGui.QCheckBox(self.OptionsBasic) self.QualityBox = QtGui.QCheckBox(self.OptionsBasic)
self.HQPVBox.setGeometry(QtCore.QRect(282, 10, 130, 18)) self.QualityBox.setGeometry(QtCore.QRect(282, 10, 130, 18))
self.HQPVBox.setFocusPolicy(QtCore.Qt.NoFocus) self.QualityBox.setFocusPolicy(QtCore.Qt.NoFocus)
self.HQPVBox.setChecked(True) self.QualityBox.setTristate(True)
self.HQPVBox.setObjectName(_fromUtf8("HQPVBox")) self.QualityBox.setObjectName(_fromUtf8("QualityBox"))
self.RotateBox = QtGui.QCheckBox(self.OptionsBasic) self.RotateBox = QtGui.QCheckBox(self.OptionsBasic)
self.RotateBox.setGeometry(QtCore.QRect(145, 10, 130, 18)) self.RotateBox.setGeometry(QtCore.QRect(145, 10, 130, 18))
self.RotateBox.setFocusPolicy(QtCore.Qt.NoFocus) self.RotateBox.setFocusPolicy(QtCore.Qt.NoFocus)
@@ -270,11 +270,11 @@ class Ui_KCC(object):
KCC.setWindowTitle(_translate("KCC", "Kindle Comic Converter", None)) KCC.setWindowTitle(_translate("KCC", "Kindle Comic Converter", None))
self.ProcessingBox.setToolTip(_translate("KCC", "Disable image optimizations.", None)) self.ProcessingBox.setToolTip(_translate("KCC", "Disable image optimizations.", None))
self.ProcessingBox.setText(_translate("KCC", "No optimisation", 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.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.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.NoDitheringBox.setText(_translate("KCC", "PNG output", None))
self.BorderBox.setToolTip(_translate("KCC", "Fill space around images with black color.", None)) self.BorderBox.setToolTip(_translate("KCC", "Fill space around images with black color.", None))
self.BorderBox.setText(_translate("KCC", "Black borders", 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.ClearButton.setText(_translate("KCC", "Clear list", None))
self.MangaBox.setToolTip(_translate("KCC", "Enable right-to-left reading.", None)) self.MangaBox.setToolTip(_translate("KCC", "Enable right-to-left reading.", None))
self.MangaBox.setText(_translate("KCC", "Manga mode", 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.QualityBox.setToolTip(_translate("KCC", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
self.HQPVBox.setText(_translate("KCC", "HQ Panel View", None)) "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
self.RotateBox.setToolTip(_translate("KCC", "<html><head/><body><p>Disable page spliting.</p><p>They will be rotated instead.</p></body></html>", None)) "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.RotateBox.setText(_translate("KCC", "Horizontal mode", None))
self.BasicModeButton.setText(_translate("KCC", "Basic", None)) self.BasicModeButton.setText(_translate("KCC", "Basic", None))
self.AdvModeButton.setText(_translate("KCC", "Advanced", None)) self.AdvModeButton.setText(_translate("KCC", "Advanced", None))
+19 -13
View File
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'KCC-OSX.ui' # 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 # by: PyQt4 UI code generator 4.10.1
# #
# WARNING! All changes made in this file will be lost! # 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.setFocusPolicy(QtCore.Qt.NoFocus)
self.MangaBox.setChecked(True) self.MangaBox.setChecked(True)
self.MangaBox.setObjectName(_fromUtf8("MangaBox")) self.MangaBox.setObjectName(_fromUtf8("MangaBox"))
self.HQPVBox = QtGui.QCheckBox(self.OptionsBasic) self.QualityBox = QtGui.QCheckBox(self.OptionsBasic)
self.HQPVBox.setGeometry(QtCore.QRect(282, 10, 130, 18)) self.QualityBox.setGeometry(QtCore.QRect(282, 10, 130, 18))
font = QtGui.QFont() font = QtGui.QFont()
font.setPointSize(11) font.setPointSize(11)
self.HQPVBox.setFont(font) self.QualityBox.setFont(font)
self.HQPVBox.setFocusPolicy(QtCore.Qt.NoFocus) self.QualityBox.setFocusPolicy(QtCore.Qt.NoFocus)
self.HQPVBox.setChecked(True) self.QualityBox.setTristate(True)
self.HQPVBox.setObjectName(_fromUtf8("HQPVBox")) self.QualityBox.setObjectName(_fromUtf8("QualityBox"))
self.RotateBox = QtGui.QCheckBox(self.OptionsBasic) self.RotateBox = QtGui.QCheckBox(self.OptionsBasic)
self.RotateBox.setGeometry(QtCore.QRect(145, 10, 130, 18)) self.RotateBox.setGeometry(QtCore.QRect(145, 10, 130, 18))
font = QtGui.QFont() font = QtGui.QFont()
@@ -329,11 +329,11 @@ class Ui_KCC(object):
KCC.setWindowTitle(_translate("KCC", "Kindle Comic Converter", None)) KCC.setWindowTitle(_translate("KCC", "Kindle Comic Converter", None))
self.ProcessingBox.setToolTip(_translate("KCC", "Disable image optimizations.", None)) self.ProcessingBox.setToolTip(_translate("KCC", "Disable image optimizations.", None))
self.ProcessingBox.setText(_translate("KCC", "No optimisation", 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.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.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.NoDitheringBox.setText(_translate("KCC", "PNG output", None))
self.BorderBox.setToolTip(_translate("KCC", "Fill space around images with black color.", None)) self.BorderBox.setToolTip(_translate("KCC", "Fill space around images with black color.", None))
self.BorderBox.setText(_translate("KCC", "Black borders", 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.ClearButton.setText(_translate("KCC", "Clear list", None))
self.MangaBox.setToolTip(_translate("KCC", "Enable right-to-left reading.", None)) self.MangaBox.setToolTip(_translate("KCC", "Enable right-to-left reading.", None))
self.MangaBox.setText(_translate("KCC", "Manga mode", 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.QualityBox.setToolTip(_translate("KCC", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
self.HQPVBox.setText(_translate("KCC", "HQ Panel View", None)) "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
self.RotateBox.setToolTip(_translate("KCC", "<html><head/><body><p>Disable page spliting.</p><p>They will be rotated instead.</p></body></html>", None)) "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.RotateBox.setText(_translate("KCC", "Horizontal mode", None))
self.BasicModeButton.setText(_translate("KCC", "Basic", None)) self.BasicModeButton.setText(_translate("KCC", "Basic", None))
self.AdvModeButton.setText(_translate("KCC", "Advanced", None)) self.AdvModeButton.setText(_translate("KCC", "Advanced", None))
+68 -30
View File
@@ -26,12 +26,13 @@ import os
import sys import sys
import tempfile import tempfile
import re import re
import stat
import string
from shutil import move from shutil import move
from shutil import copyfile from shutil import copyfile
from shutil import copytree from shutil import copytree
from shutil import rmtree from shutil import rmtree
from shutil import make_archive from shutil import make_archive
from stat import S_IWRITE
from optparse import OptionParser from optparse import OptionParser
from multiprocessing import Pool, Queue, freeze_support from multiprocessing import Pool, Queue, freeze_support
try: try:
@@ -47,7 +48,7 @@ def buildHTML(path, imgfile):
filename = getImageFileName(imgfile) filename = getImageFileName(imgfile)
if filename is not None: if filename is not None:
# All files marked with this sufix need horizontal Panel View. # All files marked with this sufix need horizontal Panel View.
if "_rotated" in str(filename): if "_kccrotated" in str(filename):
rotate = True rotate = True
else: else:
rotate = False rotate = False
@@ -123,19 +124,24 @@ def buildHTML(path, imgfile):
"<div id=\"BoxBR\"><a class=\"app-amzn-magnify\" data-app-amzn-magnify=" "<div id=\"BoxBR\"><a class=\"app-amzn-magnify\" data-app-amzn-magnify="
"'{\"targetId\":\"BoxBR-Panel-Parent\", \"ordinal\":4}'></a></div>\n" "'{\"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=\"", 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", imgfilepv, "\"/></div></div>\n",
"<div id=\"BoxTR-Panel-Parent\" class=\"target-mag-parent\"><div id=\"BoxTR-Panel\" class=\"", "<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", imgfilepv, "\"/></div></div>\n",
"<div id=\"BoxBL-Panel-Parent\" class=\"target-mag-parent\"><div id=\"BoxBL-Panel\" class=\"", "<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", imgfilepv, "\"/></div></div>\n",
"<div id=\"BoxBR-Panel-Parent\" class=\"target-mag-parent\"><div id=\"BoxBR-Panel\" class=\"", "<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" imgfilepv, "\"/></div></div>\n"
]) ])
f.writelines(["</div>\n</body>\n</html>"]) f.writelines(["</div>\n</body>\n</html>"])
f.close() f.close()
@@ -261,7 +267,7 @@ def buildOPF(dstdir, title, filelist, cover=None):
f.write("</manifest>\n<spine toc=\"ncx\">\n") f.write("</manifest>\n<spine toc=\"ncx\">\n")
splitCountUsed = 1 splitCountUsed = 1
for entry in reflist: for entry in reflist:
if entry.endswith("-kcca"): if "_kcca" in str(entry):
# noinspection PyRedundantParentheses # noinspection PyRedundantParentheses
if ((options.righttoleft and facing == 'left') or (not options.righttoleft and facing == 'right')) and\ if ((options.righttoleft and facing == 'left') or (not options.righttoleft and facing == 'right')) and\
options.landscapemode: options.landscapemode:
@@ -271,7 +277,7 @@ def buildOPF(dstdir, title, filelist, cover=None):
f.write("<itemref idref=\"page_" + entry + "\" properties=\"page-spread-" + facing1 + "\"/>\n") f.write("<itemref idref=\"page_" + entry + "\" properties=\"page-spread-" + facing1 + "\"/>\n")
else: else:
f.write("<itemref idref=\"page_" + entry + "\"/>\n") f.write("<itemref idref=\"page_" + entry + "\"/>\n")
elif entry.endswith("-kccb"): elif "_kccb" in str(entry):
if options.landscapemode: if options.landscapemode:
f.write("<itemref idref=\"page_" + entry + "\" properties=\"page-spread-" + facing2 + "\"/>\n") f.write("<itemref idref=\"page_" + entry + "\" properties=\"page-spread-" + facing2 + "\"/>\n")
else: else:
@@ -320,12 +326,16 @@ def getImageFileName(imgfile):
return filename return filename
def applyImgOptimization(img, isSplit, toRight, options): def applyImgOptimization(img, isSplit, toRight, options, overrideQuality=5):
img.cropWhiteSpace(10.0) img.cropWhiteSpace(10.0)
if options.cutpagenumbers: if options.cutpagenumbers:
img.cutPageNumber() img.cutPageNumber()
img.resizeImage(options.upscale, options.stretch, options.black_borders, isSplit, toRight, options.landscapemode, if overrideQuality != 5:
options.nopanelviewhq) 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) img.optimizeImage(options.gamma)
if options.forcepng: if options.forcepng:
img.quantizeImage() img.quantizeImage()
@@ -358,7 +368,11 @@ def dirImgProcess(path):
GUI.emit(QtCore.SIGNAL("progressBarTick")) GUI.emit(QtCore.SIGNAL("progressBarTick"))
pool.join() pool.join()
queue.close() queue.close()
splitpages = splitpages.get() try:
splitpages = splitpages.get()
except:
rmtree(path)
raise RuntimeError("One of workers crashed. Cause: " + str(sys.exc_info()[1]))
splitpages = filter(None, splitpages) splitpages = filter(None, splitpages)
splitpages.sort() splitpages.sort()
for page in splitpages: for page in splitpages:
@@ -386,6 +400,10 @@ def fileImgProcess(work):
print ".", print ".",
fileImgProcess.queue.put(".") fileImgProcess.queue.put(".")
img = image.ComicPage(os.path.join(dirpath, afile), options.profileData) img = image.ComicPage(os.path.join(dirpath, afile), options.profileData)
if options.quality == 2:
wipe = False
else:
wipe = True
if options.nosplitrotate: if options.nosplitrotate:
split = None split = None
else: else:
@@ -402,13 +420,26 @@ def fileImgProcess(work):
output = pagenumber output = pagenumber
img0 = image.ComicPage(split[0], options.profileData) img0 = image.ComicPage(split[0], options.profileData)
applyImgOptimization(img0, True, toRight1, options) 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) img1 = image.ComicPage(split[1], options.profileData)
applyImgOptimization(img1, True, toRight2, options) applyImgOptimization(img1, True, toRight2, options)
img1.saveToDir(dirpath, options.forcepng, options.forcecolor) img1.saveToDir(dirpath, options.forcepng, options.forcecolor, wipe)
if options.quality == 2:
img3 = image.ComicPage(split[0], options.profileData)
applyImgOptimization(img3, True, toRight1, options, 0)
img3.saveToDir(dirpath, options.forcepng, options.forcecolor, True)
img4 = image.ComicPage(split[1], options.profileData)
applyImgOptimization(img4, True, toRight2, options, 0)
img4.saveToDir(dirpath, options.forcepng, options.forcecolor, True)
else: else:
applyImgOptimization(img, False, False, options) 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)
if split == "R":
img2.image = img2.image.rotate(90)
applyImgOptimization(img2, False, False, options, 0)
img2.saveToDir(dirpath, options.forcepng, options.forcecolor, True, split)
return output return output
@@ -544,7 +575,7 @@ def genEpubStruct(path):
chapter = False chapter = False
for afile in filenames: for afile in filenames:
filename = getImageFileName(afile) filename = getImageFileName(afile)
if filename is not None: if filename is not None and not "_kcchq" in filename[0]:
filelist.append(buildHTML(dirpath, afile)) filelist.append(buildHTML(dirpath, afile))
if not chapter: if not chapter:
chapterlist.append((dirpath.replace('Images', 'Text'), filelist[-1][1])) chapterlist.append((dirpath.replace('Images', 'Text'), filelist[-1][1]))
@@ -569,10 +600,10 @@ def getWorkFolder(afile):
os.rmdir(workdir) # needed for copytree() fails if dst already exists os.rmdir(workdir) # needed for copytree() fails if dst already exists
fullPath = os.path.join(workdir, 'OEBPS', 'Images') fullPath = os.path.join(workdir, 'OEBPS', 'Images')
copytree(afile, fullPath) copytree(afile, fullPath)
if sys.platform == 'win32': sanitizeTreeBeforeConversion(fullPath)
sanitizeTreeReadOnly(fullPath)
return workdir return workdir
except OSError: except OSError:
rmtree(workdir)
raise raise
elif afile.lower().endswith('.pdf'): elif afile.lower().endswith('.pdf'):
pdf = pdfjpgextract.PdfJpgExtract(afile) pdf = pdfjpgextract.PdfJpgExtract(afile)
@@ -583,10 +614,12 @@ def getWorkFolder(afile):
try: try:
path = cbx.extract(workdir) path = cbx.extract(workdir)
except OSError: except OSError:
rmtree(workdir)
print 'Unrar not found, please download from ' + \ print 'Unrar not found, please download from ' + \
'http://www.rarlab.com/download.htm and put into your PATH.' 'http://www.rarlab.com/download.htm and put into your PATH.'
sys.exit(21) sys.exit(21)
else: else:
rmtree(workdir)
raise TypeError raise TypeError
move(path, path + "_temp") move(path, path + "_temp")
move(path + "_temp", os.path.join(path, 'OEBPS', 'Images')) move(path + "_temp", os.path.join(path, 'OEBPS', 'Images'))
@@ -625,12 +658,15 @@ def sanitizeTree(filetree):
os.rename(os.path.join(root, name), os.path.join(root, slugify(name))) os.rename(os.path.join(root, name), os.path.join(root, slugify(name)))
def sanitizeTreeReadOnly(filetree): def sanitizeTreeBeforeConversion(filetree):
for root, dirs, files in os.walk(filetree, False): for root, dirs, files in os.walk(filetree, False):
for name in files: for name in files:
os.chmod(os.path.join(root, name), S_IWRITE) os.chmod(os.path.join(root, name), stat.S_IWRITE | stat.S_IREAD)
# Detect corrupted files - Phase 1
if os.path.getsize(os.path.join(root, name)) == 0:
os.remove(os.path.join(root, name))
for name in dirs: for name in dirs:
os.chmod(os.path.join(root, name), S_IWRITE) os.chmod(os.path.join(root, name), stat.S_IWRITE | stat.S_IREAD)
def Copyright(): def Copyright():
@@ -654,10 +690,10 @@ def main(argv=None, qtGUI=None):
help="Comic title [Default=filename]") help="Comic title [Default=filename]")
parser.add_option("-m", "--manga-style", action="store_true", dest="righttoleft", default=False, parser.add_option("-m", "--manga-style", action="store_true", dest="righttoleft", default=False,
help="Manga style (Right-to-left reading and splitting) [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, parser.add_option("-c", "--cbz-output", action="store_true", dest="cbzoutput", default=False,
help="Outputs a CBZ archive and does not generate EPUB") 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, parser.add_option("--noprocessing", action="store_false", dest="imgproc", default=True,
help="Do not apply image preprocessing (Page splitting and optimizations) [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, parser.add_option("--forcepng", action="store_true", dest="forcepng", default=False,
@@ -752,9 +788,11 @@ def checkOptions():
else: else:
options.landscapemode = False options.landscapemode = False
# Older Kindle don't support Virtual Panel View. We providing them configuration that will fake that feature. # 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 # Real Panel View
options.panelview = True options.panelview = True
options.landscapemode = False
else: else:
# Virtual Panel View # Virtual Panel View
options.panelview = False options.panelview = False
@@ -762,7 +800,7 @@ def checkOptions():
# Kindle Fire family have very high resolution. Bigger images are not needed. # 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'\ 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': 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. # Disabling grayscale conversion for Kindle Fire family.
# Forcing JPEG output. For now code can't provide color PNG files. # 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: if options.profile == 'KF' or options.profile == 'KFHD' or options.profile == 'KFHD8' or options.forcecolor:
+21 -12
View File
@@ -116,28 +116,37 @@ class ComicPage:
self.profile_label, self.size, self.palette, self.gamma, self.panelviewsize = device self.profile_label, self.size, self.palette, self.gamma, self.panelviewsize = device
except KeyError: except KeyError:
raise RuntimeError('Unexpected output device %s' % device) raise RuntimeError('Unexpected output device %s' % device)
# Detect corrupted files - Phase 2
try: try:
self.origFileName = source self.origFileName = source
self.image = Image.open(source) self.image = Image.open(source)
except IOError: except IOError:
raise RuntimeError('Cannot read image file %s' % source) raise RuntimeError('Cannot read image file %s' % source)
# Detect corrupted files - Phase 3
try:
self.image.verify()
except:
raise RuntimeError('Image file %s is corrupted' % source)
self.image = Image.open(source)
self.image = self.image.convert('RGB') self.image = self.image.convert('RGB')
def saveToDir(self, targetdir, forcepng, color, suffix=None): def saveToDir(self, targetdir, forcepng, color, wipe, sufix=None):
filename = os.path.basename(self.origFileName) filename = os.path.basename(self.origFileName)
try: try:
if not color: if not color:
self.image = self.image.convert('L') # convert to grayscale self.image = self.image.convert('L') # convert to grayscale
# Suffix is used to recognise which files need horizontal Panel View. if sufix == "R":
if suffix == "R": sufix = "_kccrotated"
suffix = "_rotated"
else: else:
suffix = "" sufix = ""
os.remove(os.path.join(targetdir, filename)) if wipe:
os.remove(os.path.join(targetdir, filename))
else:
sufix += "_kcchq"
if forcepng: if forcepng:
self.image.save(os.path.join(targetdir, os.path.splitext(filename)[0] + suffix + ".png"), "PNG") self.image.save(os.path.join(targetdir, os.path.splitext(filename)[0] + sufix + ".png"), "PNG")
else: else:
self.image.save(os.path.join(targetdir, os.path.splitext(filename)[0] + suffix + ".jpg"), "JPEG") self.image.save(os.path.join(targetdir, os.path.splitext(filename)[0] + sufix + ".jpg"), "JPEG")
except IOError as e: except IOError as e:
raise RuntimeError('Cannot write image in directory %s: %s' % (targetdir, e)) raise RuntimeError('Cannot write image in directory %s: %s' % (targetdir, e))
@@ -160,13 +169,13 @@ class ComicPage:
self.image = self.image.quantize(palette=palImg) self.image = self.image.quantize(palette=palImg)
def resizeImage(self, upscale=False, stretch=False, black_borders=False, isSplit=False, toRight=False, 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 method = Image.ANTIALIAS
if black_borders: if black_borders:
fill = 'black' fill = 'black'
else: else:
fill = 'white' fill = 'white'
if noPanelViewHQ: if qualityMode == 0:
size = (self.size[0], self.size[1]) size = (self.size[0], self.size[1])
else: else:
size = (self.panelviewsize[0], self.panelviewsize[1]) size = (self.panelviewsize[0], self.panelviewsize[1])
@@ -222,8 +231,8 @@ class ComicPage:
leftbox = (0, 0, width, height / 2) leftbox = (0, 0, width, height / 2)
rightbox = (0, height / 2, width, height) rightbox = (0, height / 2, width, height)
filename = os.path.splitext(os.path.basename(self.origFileName)) filename = os.path.splitext(os.path.basename(self.origFileName))
fileone = targetdir + '/' + filename[0] + '-kcca' + filename[1] fileone = targetdir + '/' + filename[0] + '_kcca' + filename[1]
filetwo = targetdir + '/' + filename[0] + '-kccb' + filename[1] filetwo = targetdir + '/' + filename[0] + '_kccb' + filename[1]
try: try:
if righttoleft: if righttoleft:
pageone = self.image.crop(rightbox) pageone = self.image.crop(rightbox)