From e9d82cc0efb90200e199c9982d80cf5940257a31 Mon Sep 17 00:00:00 2001
From: Baitinq
Date: Tue, 8 Feb 2022 16:54:24 +0000
Subject: Add outputMerge option (removed outputSplit)
---
gui/KCC.ui | 10 ++++++++++
kindlecomicconverter/KCC_gui.py | 33 +++++++++++++++++++++++++++++++++
kindlecomicconverter/KCC_ui.py | 18 +++++++++++++-----
kindlecomicconverter/image.py | 2 +-
4 files changed, 57 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 @@
-
+
+
+
+ <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>
+
+
+ Output Join
+
+
-
diff --git a/kindlecomicconverter/KCC_gui.py b/kindlecomicconverter/KCC_gui.py
index 56b00c5..fb10853 100644
--- a/kindlecomicconverter/KCC_gui.py
+++ b/kindlecomicconverter/KCC_gui.py
@@ -286,6 +286,39 @@ class WorkerThread(QtCore.QThread):
if GUI.jobList.item(i).icon().isNull():
currentJobs.append(str(GUI.jobList.item(i).text()))
GUI.jobList.clear()
+
+ #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 = os.path.relpath(p, start=workdir)
+ zf.write(p, arcname=arcname)#change arcname to remove tmp folder (relative path)
+ zf.close()
+
+ currentJobs = [zf.filename]
+
+ GUI.progress.content = ''
+
for job in currentJobs:
sleep(0.5)
if not self.conversionAlive:
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", "
Unchecked - Autodetection
The color of margins fill will be detected automatically.
Indeterminate - White
Margins will be filled with white color.
Checked - Black
Margins will be filled with black color.
"))
self.borderBox.setText(_translate("mainWindow", "W/B margins"))
- self.outputSplit.setToolTip(_translate("mainWindow", " Unchecked - Automatic mode
The output will be split automatically.
Checked - Volume mode
Every subdirectory will be considered as a separate volume.
"))
- self.outputSplit.setText(_translate("mainWindow", "Output split"))
+ #self.outputSplit.setToolTip(_translate("mainWindow", "
Unchecked - Automatic mode
The output will be split automatically.
Checked - Volume mode
Every subdirectory will be considered as a separate volume.
"))
+ #self.outputSplit.setText(_translate("mainWindow", "Output split"))
+ self.outputMerge.setToolTip(_translate("mainWindow", "Unchecked - Automatic mode
The output will be split automatically.
Checked - Volume mode
Every subdirectory will be considered as a separate volume.
"))
+ self.outputMerge.setText(_translate("mainWindow", "Output Merge"))
self.colorBox.setToolTip(_translate("mainWindow", "Disable conversion to grayscale.
"))
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 2bcee16..a627941 100755
--- a/kindlecomicconverter/image.py
+++ b/kindlecomicconverter/image.py
@@ -258,7 +258,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
--
cgit 1.4.1