From 61f3097be5eb8ba75e03c072e8837e59df96d72e Mon Sep 17 00:00:00 2001 From: Alex Xu Date: Sat, 11 Apr 2026 19:09:04 -0700 Subject: [PATCH] smart cover crop is now an option default off (#1288) --- README.md | 1 + gui/KCC.ui | 10 ++++++++++ kindlecomicconverter/KCC_gui.py | 3 +++ kindlecomicconverter/KCC_ui.py | 9 +++++++++ kindlecomicconverter/comic2ebook.py | 2 ++ kindlecomicconverter/image.py | 3 ++- 6 files changed, 27 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 14501b2..a01159d 100644 --- a/README.md +++ b/README.md @@ -270,6 +270,7 @@ PROCESSING: Crop empty sections. 0: Disabled 1: Horizontally 2: Both [Default=0] --blackborders Disable autodetection and force black borders --whiteborders Disable autodetection and force white borders + --smartcovercrop Attempt to crop main cover from wide image --coverfill Center-crop only the cover to fill target device screen --forcecolor Don't convert images to grayscale --forcepng Create PNG files instead JPEG for black and white images diff --git a/gui/KCC.ui b/gui/KCC.ui index 4e75811..1767b25 100644 --- a/gui/KCC.ui +++ b/gui/KCC.ui @@ -975,6 +975,16 @@ May crop top/bottom or left/right depending on source aspect ratio. Not implemen + + + + Attempt to crop main cover from wide image. + + + Smart Cover Crop + + + diff --git a/kindlecomicconverter/KCC_gui.py b/kindlecomicconverter/KCC_gui.py index 87910d5..c67e2bb 100644 --- a/kindlecomicconverter/KCC_gui.py +++ b/kindlecomicconverter/KCC_gui.py @@ -331,6 +331,8 @@ class WorkerThread(QThread): options.pdfextract = True if GUI.pdfWidthBox.isChecked(): options.pdfwidth = True + if GUI.smartCoverCropBox.isChecked(): + options.smartcovercrop = True if GUI.coverFillBox.isChecked(): options.coverfill = True if GUI.metadataTitleBox.checkState() == Qt.CheckState.PartiallyChecked: @@ -1053,6 +1055,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow): 'disableProcessingBox': GUI.disableProcessingBox.checkState(), 'pdfExtractBox': GUI.pdfExtractBox.checkState(), 'pdfWidthBox': GUI.pdfWidthBox.checkState(), + 'smartCoverCropBox': GUI.smartCoverCropBox.checkState(), 'coverFillBox': GUI.coverFillBox.checkState(), 'metadataTitleBox': GUI.metadataTitleBox.checkState(), 'mozJpegBox': GUI.mozJpegBox.checkState(), diff --git a/kindlecomicconverter/KCC_ui.py b/kindlecomicconverter/KCC_ui.py index 5f0c473..473a2e9 100644 --- a/kindlecomicconverter/KCC_ui.py +++ b/kindlecomicconverter/KCC_ui.py @@ -497,6 +497,11 @@ class Ui_mainWindow(object): self.gridLayout_2.addWidget(self.forcePngRgbBox, 11, 2, 1, 1) + self.smartCoverCropBox = QCheckBox(self.optionWidget) + self.smartCoverCropBox.setObjectName(u"smartCoverCropBox") + + self.gridLayout_2.addWidget(self.smartCoverCropBox, 11, 1, 1, 1) + self.gridLayout.addWidget(self.optionWidget, 5, 0, 1, 2) @@ -806,6 +811,10 @@ class Ui_mainWindow(object): self.forcePngRgbBox.setToolTip(QCoreApplication.translate("mainWindow", u"Force full color images to be saved in lossless PNG format, dramatically increases the filesize.", None)) #endif // QT_CONFIG(tooltip) self.forcePngRgbBox.setText(QCoreApplication.translate("mainWindow", u"Force PNG RGB", None)) +#if QT_CONFIG(tooltip) + self.smartCoverCropBox.setToolTip(QCoreApplication.translate("mainWindow", u"Attempt to crop main cover from wide image.", None)) +#endif // QT_CONFIG(tooltip) + self.smartCoverCropBox.setText(QCoreApplication.translate("mainWindow", u"Smart Cover Crop", None)) self.gammaLabel.setText(QCoreApplication.translate("mainWindow", u"Gamma: Auto", None)) self.jpegQualityLabel.setText(QCoreApplication.translate("mainWindow", u"JPEG Quality:", None)) # retranslateUi diff --git a/kindlecomicconverter/comic2ebook.py b/kindlecomicconverter/comic2ebook.py index 82ceba6..00ba009 100755 --- a/kindlecomicconverter/comic2ebook.py +++ b/kindlecomicconverter/comic2ebook.py @@ -1376,6 +1376,8 @@ def makeParser(): help="Use the legacy PDF image extraction method from KCC 8 and earlier") processing_options.add_argument("--pdfwidth", action="store_true", dest="pdfwidth", default=False, help="Render vector PDFs to device width instead of height.") + processing_options.add_argument("--smartcovercrop", action="store_true", dest="smartcovercrop", default=False, + help="Attempt to crop main cover from wide image") processing_options.add_argument("--coverfill", action="store_true", dest="coverfill", default=False, help="Crop cover to fill screen") processing_options.add_argument("-u", "--upscale", action="store_true", dest="upscale", default=False, diff --git a/kindlecomicconverter/image.py b/kindlecomicconverter/image.py index 816952d..1795a0f 100755 --- a/kindlecomicconverter/image.py +++ b/kindlecomicconverter/image.py @@ -572,7 +572,8 @@ class Cover: self.image = ImageOps.autocontrast(self.image, preserve_tone=True) if not self.options.forcecolor: self.image = self.image.convert('L') - self.crop_main_cover() + if self.options.smartcovercrop: + self.crop_main_cover() size = list(self.options.profileData[1]) if self.options.kindle_scribe_azw3: