From adac558aabb64e292eb13937b51a8bbd07433e45 Mon Sep 17 00:00:00 2001
From: Alex Xu
Date: Wed, 26 Aug 2026 13:05:14 -0700
Subject: [PATCH] shift click label spreads for HQ preview (#1427)
---
gui/KCC.ui | 3 +++
kindlecomicconverter/KCC_gui.py | 30 +++++++++++++++++++-----------
kindlecomicconverter/KCC_ui.py | 3 +++
3 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/gui/KCC.ui b/gui/KCC.ui
index acfe7a60..25d0c401 100644
--- a/gui/KCC.ui
+++ b/gui/KCC.ui
@@ -779,6 +779,9 @@ Keeping this file may crash some readers like the Kobo native CBZ reader.30
+
+ Hold shift while clicking for a higher quality preview.
+
Label Spreads
diff --git a/kindlecomicconverter/KCC_gui.py b/kindlecomicconverter/KCC_gui.py
index d9dff252..c3f24078 100644
--- a/kindlecomicconverter/KCC_gui.py
+++ b/kindlecomicconverter/KCC_gui.py
@@ -671,6 +671,9 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
GUI.jobList.scrollToBottom()
def labelSpreadsStart(self):
+ low_quality_preview = True
+ if QApplication.keyboardModifiers() == Qt.ShiftModifier:
+ low_quality_preview = False
currentJobs = []
# TODO: make this a function since it's copy pasted
for i in range(GUI.jobList.count()):
@@ -704,29 +707,34 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
continue
# TODO: with statements
# TODO: ignore 1% of top and bottom too?
- im1 = Image.open(os.path.join(root, files[i])).convert('1', dither=Dither.NONE)
+ im1 = Image.open(os.path.join(root, files[i]))
size1 = im1.size
- crop1 = im1.crop((0, 0, 0.2*size1[0], size1[1]))
- crop11 = im1.crop((0.01*size1[0], 0, 0.04*size1[0], size1[1]))
+ preview_crop1 = im1.crop((0, 0, 0.2*size1[0], size1[1]))
+ if low_quality_preview:
+ preview_crop1 = preview_crop1.convert('1', dither=Dither.NONE)
+ calculation_crop1 = im1.crop((0.01*size1[0], 0, 0.04*size1[0], size1[1])).convert('1', dither=Dither.NONE)
#crop1 = crop11
- im2 = Image.open(os.path.join(root, files[i+1])).convert('1', dither=Dither.NONE)
+ im2 = Image.open(os.path.join(root, files[i+1]))
size2 = im2.size
- crop2 = im2.crop((0.8*size2[0], 0, size2[0], size2[1]))
- crop22 = im2.crop((0.96*size2[0], 0, .99* size2[0], size2[1]))
+ preview_crop2 = im2.crop((0.8*size2[0], 0, size2[0], size2[1]))
+ if low_quality_preview:
+ preview_crop2 = preview_crop2.convert('1', dither=Dither.NONE)
+ calculation_crop2 = im2.crop((0.96*size2[0], 0, .99* size2[0], size2[1])).convert('1', dither=Dither.NONE)
#crop2 = crop22
# dst = Image.new('1', (im1.width + im2.width, im1.height))
# dst.paste(im2, (0, 0))
# dst.paste(im1, (im1.width, 0))
- hist1 = crop11.histogram()
- hist2 = crop22.histogram()
+ hist1 = calculation_crop1.histogram()
+ hist2 = calculation_crop2.histogram()
# TODO: small percentage instead of zero
if hist1[0] == 0 or hist1[-1] == 0 or hist2[0] == 0 or hist2[-1] == 0:
continue
- dst = Image.new('1', (crop1.width + crop2.width, crop1.height))
+ preview_mode = '1' if low_quality_preview else 'RGB'
+ dst = Image.new(preview_mode, (preview_crop1.width + preview_crop2.width, preview_crop1.height))
- dst.paste(crop2, (0, 0))
- dst.paste(crop1, (crop1.width, 0))
+ dst.paste(preview_crop2, (0, 0))
+ dst.paste(preview_crop1, (preview_crop1.width, 0))
dst.save(os.path.join(workdir, f'label-{i:04}.png'))
images.append(os.path.join(workdir, f'label-{i:04}.png'))
diff --git a/kindlecomicconverter/KCC_ui.py b/kindlecomicconverter/KCC_ui.py
index 9c777dac..6a726de2 100644
--- a/kindlecomicconverter/KCC_ui.py
+++ b/kindlecomicconverter/KCC_ui.py
@@ -860,6 +860,9 @@ class Ui_mainWindow(object):
self.editorButton.setText(QCoreApplication.translate("mainWindow", u"Metadata Editor", None))
self.humbleButton.setText(QCoreApplication.translate("mainWindow", u"Humble Bundle Referral", None))
self.kofiButton.setText(QCoreApplication.translate("mainWindow", u"Support me on Ko-fi", None))
+#if QT_CONFIG(tooltip)
+ self.labelSpreadsButton.setToolTip(QCoreApplication.translate("mainWindow", u"Hold shift while clicking for a higher quality preview.", None))
+#endif // QT_CONFIG(tooltip)
self.labelSpreadsButton.setText(QCoreApplication.translate("mainWindow", u"Label Spreads", None))
#if QT_CONFIG(tooltip)
self.chunkSizeWidget.setToolTip(QCoreApplication.translate("mainWindow", u"
Warning: chunk size greater than default may cause
performance/battery issues, especially on older devices.
", None))