diff options
author | Baitinq <you@example.com> | 2022-02-08 16:37:59 +0000 |
---|---|---|
committer | Baitinq <you@example.com> | 2022-02-08 16:37:59 +0000 |
commit | 73cd0dd107901bebe7d72e2b86ecf8b830a19758 (patch) | |
tree | 280efd18cebca3fbb6c71364157830c0f722c0ec | |
parent | Merge pull request #329 from C0rn3j/master (diff) | |
download | kcc-master.tar.gz kcc-master.tar.bz2 kcc-master.zip |
-rw-r--r-- | gui/KCC.ui | 10 | ||||
-rw-r--r-- | kindlecomicconverter/KCC_gui.py | 38 | ||||
-rw-r--r-- | kindlecomicconverter/KCC_ui.py | 18 | ||||
-rwxr-xr-x | kindlecomicconverter/image.py | 2 |
4 files changed, 62 insertions, 6 deletions
diff --git a/gui/KCC.ui b/gui/KCC.ui index 09a7b92..86d76de 100644 --- a/gui/KCC.ui +++ b/gui/KCC.ui @@ -231,6 +231,7 @@ </widget> </item> <item row="2" column="1"> + <!-- <widget class="QCheckBox" name="outputSplit"> <property name="toolTip"> <string><html><head/><body><p style='white-space:pre'><span style=" font-weight:600; text-decoration: underline;">Unchecked - Automatic mode<br/></span>The output will be split automatically.</p><p style='white-space:pre'><span style=" font-weight:600; text-decoration: underline;">Checked - Volume mode<br/></span>Every subdirectory will be considered as a separate volume.</p></body></html></string> @@ -239,6 +240,15 @@ <string>Output split</string> </property> </widget> + --> + <widget class="QCheckBox" name="outputJoin"> + <property name="toolTip"> + <string><html><head/><body><p style='white-space:pre'><span style=" font-weight:600; text-decoration: underline;">Unchecked - Automatic mode<br/></span>The output will be split automatically.</p><p style='white-space:pre'><span style=" font-weight:600; text-decoration: underline;">Checked - Volume mode<br/></span>Every subdirectory will be considered as a separate volume.</p></body></html></string> + </property> + <property name="text"> + <string>Output Join</string> + </property> + </widget> </item> <item row="2" column="2"> <widget class="QCheckBox" name="colorBox"> diff --git a/kindlecomicconverter/KCC_gui.py b/kindlecomicconverter/KCC_gui.py index 50e91dd..8765b7e 100644 --- a/kindlecomicconverter/KCC_gui.py +++ b/kindlecomicconverter/KCC_gui.py @@ -285,7 +285,44 @@ class WorkerThread(QtCore.QThread): # Make sure that we don't consider any system message as job to do if GUI.jobList.item(i).icon().isNull(): currentJobs.append(str(GUI.jobList.item(i).text())) + GUI.jobList.clear() + + #TODO: REname outputjoin to outputmerge + #NEEDS TO BE CBR FILENAME (SO IT CAN BE EXTRACTED) + if GUI.outputMerge.isChecked(): + import zipfile + from tempfile import TemporaryDirectory + + MW.addMessage.emit('Merging all files...', 'info', False) + GUI.progress.content = 'Merging all files' + + zf = zipfile.ZipFile(currentJobs[0].split('.', 1)[0] + "-MERGED.cbz", "w") + + #we should join cbz before converting + with TemporaryDirectory('', 'KCC-') as workdir: + for job in currentJobs: + + #unzip all in tmp folder + name = os.path.splitext(os.path.basename(job))[0] + extracted_dir = workdir + "/" + name + + with zipfile.ZipFile(job, 'r') as zip_ref: + zip_ref.extractall(extracted_dir) + + for dirname, subdirs, files in os.walk(extracted_dir): + for filename in files: + p = os.path.join(dirname, filename) + arcname = name+"/"+filename + zf.write(p, arcname=arcname)#change arcname to just the chapter (no tmp folder) + + zf.close() + + currentJobs = [zf.filename] + + GUI.progress.content = '' + + #GUI.jobList.clear() for job in currentJobs: sleep(0.5) if not self.conversionAlive: @@ -396,6 +433,7 @@ class WorkerThread(QtCore.QThread): except Exception: pass MW.addMessage.emit('Processing MOBI files... <b>Done!</b>', 'info', True) + #print(str(currentJobs)) k = kindle.Kindle() if k.path and k.coverSupport: for item in outputPath: diff --git a/kindlecomicconverter/KCC_ui.py b/kindlecomicconverter/KCC_ui.py index b70f3ef..0a60c17 100644 --- a/kindlecomicconverter/KCC_ui.py +++ b/kindlecomicconverter/KCC_ui.py @@ -100,7 +100,11 @@ class Ui_mainWindow(object): self.gridLayout_2.addWidget(self.borderBox, 2, 0, 1, 1) self.outputSplit = QtWidgets.QCheckBox(self.optionWidget) self.outputSplit.setObjectName("outputSplit") - self.gridLayout_2.addWidget(self.outputSplit, 2, 1, 1, 1) + self.outputSplit.hide() + #self.gridLayout_2.addWidget(self.outputSplit, 2, 1, 1, 1) + self.outputMerge = QtWidgets.QCheckBox(self.optionWidget) + self.outputMerge.setObjectName("outputMerge") + self.gridLayout_2.addWidget(self.outputMerge, 2, 1, 1, 1) self.colorBox = QtWidgets.QCheckBox(self.optionWidget) self.colorBox.setObjectName("colorBox") self.gridLayout_2.addWidget(self.colorBox, 2, 2, 1, 1) @@ -220,8 +224,10 @@ class Ui_mainWindow(object): mainWindow.setTabOrder(self.webtoonBox, self.upscaleBox) mainWindow.setTabOrder(self.upscaleBox, self.gammaBox) mainWindow.setTabOrder(self.gammaBox, self.borderBox) - mainWindow.setTabOrder(self.borderBox, self.outputSplit) - mainWindow.setTabOrder(self.outputSplit, self.colorBox) + #mainWindow.setTabOrder(self.borderBox, self.outputSplit) + #mainWindow.setTabOrder(self.outputSplit, self.colorBox) + mainWindow.setTabOrder(self.borderBox, self.outputMerge) + mainWindow.setTabOrder(self.outputMerge, self.colorBox) mainWindow.setTabOrder(self.colorBox, self.editorButton) mainWindow.setTabOrder(self.editorButton, self.wikiButton) mainWindow.setTabOrder(self.wikiButton, self.jobList) @@ -252,8 +258,10 @@ class Ui_mainWindow(object): self.gammaBox.setText(_translate("mainWindow", "Custom gamma")) self.borderBox.setToolTip(_translate("mainWindow", "<html><head/><body><p><span style=\" font-weight:600; text-decoration: underline;\">Unchecked - Autodetection<br/></span>The color of margins fill will be detected automatically.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Indeterminate - White<br/></span>Margins will be filled with white color.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Checked - Black<br/></span>Margins will be filled with black color.</p></body></html>")) self.borderBox.setText(_translate("mainWindow", "W/B margins")) - self.outputSplit.setToolTip(_translate("mainWindow", "<html><head/><body><p style=\'white-space:pre\'><span style=\" font-weight:600; text-decoration: underline;\">Unchecked - Automatic mode<br/></span>The output will be split automatically.</p><p style=\'white-space:pre\'><span style=\" font-weight:600; text-decoration: underline;\">Checked - Volume mode<br/></span>Every subdirectory will be considered as a separate volume.</p></body></html>")) - self.outputSplit.setText(_translate("mainWindow", "Output split")) + #self.outputSplit.setToolTip(_translate("mainWindow", "<html><head/><body><p style=\'white-space:pre\'><span style=\" font-weight:600; text-decoration: underline;\">Unchecked - Automatic mode<br/></span>The output will be split automatically.</p><p style=\'white-space:pre\'><span style=\" font-weight:600; text-decoration: underline;\">Checked - Volume mode<br/></span>Every subdirectory will be considered as a separate volume.</p></body></html>")) + #self.outputSplit.setText(_translate("mainWindow", "Output split")) + self.outputMerge.setToolTip(_translate("mainWindow", "<html><head/><body><p style=\'white-space:pre\'><span style=\" font-weight:600; text-decoration: underline;\">Unchecked - Automatic mode<br/></span>The output will be split automatically.</p><p style=\'white-space:pre\'><span style=\" font-weight:600; text-decoration: underline;\">Checked - Volume mode<br/></span>Every subdirectory will be considered as a separate volume.</p></body></html>")) + self.outputMerge.setText(_translate("mainWindow", "Output Merge")) self.colorBox.setToolTip(_translate("mainWindow", "<html><head/><body><p style=\'white-space:pre\'>Disable conversion to grayscale.</p></body></html>")) self.colorBox.setText(_translate("mainWindow", "Color mode")) self.gammaLabel.setText(_translate("mainWindow", "Gamma: Auto")) diff --git a/kindlecomicconverter/image.py b/kindlecomicconverter/image.py index 35fcfc8..817a702 100755 --- a/kindlecomicconverter/image.py +++ b/kindlecomicconverter/image.py @@ -255,7 +255,7 @@ class ComicPage: if gamma == 1.0: self.image = ImageOps.autocontrast(self.image) else: - self.image = ImageOps.autocontrast(Image.eval(self.image, lambda a: 255 * (a / 255.) ** gamma)) + self.image = ImageOps.autocontrast(Image.eval(self.image, lambda a: int(255 * (a / 255.) ** gamma))) def quantizeImage(self): colors = len(self.palette) // 3 |