1
0
mirror of https://github.com/ciromattia/kcc synced 2026-04-13 12:29:09 +00:00

smart cover crop is now an option default off (#1288)

This commit is contained in:
Alex Xu
2026-04-11 19:09:04 -07:00
committed by GitHub
parent fa33ef8f89
commit 61f3097be5
6 changed files with 27 additions and 1 deletions

View File

@@ -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

View File

@@ -975,6 +975,16 @@ May crop top/bottom or left/right depending on source aspect ratio. Not implemen
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QCheckBox" name="smartCoverCropBox">
<property name="toolTip">
<string>Attempt to crop main cover from wide image.</string>
</property>
<property name="text">
<string>Smart Cover Crop</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@@ -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(),

View File

@@ -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

View File

@@ -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,

View File

@@ -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: