mirror of
https://github.com/ciromattia/kcc
synced 2026-05-07 00:02:22 +00:00
Compare commits
1 Commits
v10.1.3
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48e4c50c70 |
@@ -199,8 +199,6 @@ sudo apt-get install python3 p7zip-full python3-pil python3-psutil python3-slugi
|
||||
'KCS': ("Kindle Colorsoft", (1272, 1696), Palette16, 1.0),
|
||||
'KS1860': ("Kindle 1860", (1860, 1920), Palette16, 1.0),
|
||||
'KS1920': ("Kindle 1920", (1920, 1920), Palette16, 1.0),
|
||||
'KS1240': ("Kindle 1240", (1240, 1860), Palette16, 1.0),
|
||||
'KS1324': ("Kindle 1324", (1324, 1986), Palette16, 1.0),
|
||||
'KS': ("Kindle Scribe 1/2", (1860, 2480), Palette16, 1.0),
|
||||
'KS3': ("Kindle Scribe 3", (1986, 2648), Palette16, 1.0),
|
||||
'KSCS': ("Kindle Scribe Colorsoft", (1986, 2648), Palette16, 1.0),
|
||||
@@ -269,7 +267,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
|
||||
--nosmartcovercrop Disable 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
|
||||
|
||||
@@ -655,12 +655,12 @@ Higher values are larger and higher quality, and may resolve blank page issues.<
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="1">
|
||||
<widget class="QCheckBox" name="smartCoverCropBox">
|
||||
<widget class="QCheckBox" name="noSmartCoverCropBox">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Attempt to crop main cover from wide image.</p></body></html></string>
|
||||
<string>Disable attempt to crop main cover from wide image.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Smart Cover Crop</string>
|
||||
<string>No Smart Cover Crop</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -331,8 +331,8 @@ class WorkerThread(QThread):
|
||||
options.pdfextract = True
|
||||
if GUI.pdfWidthBox.isChecked():
|
||||
options.pdfwidth = True
|
||||
if GUI.smartCoverCropBox.isChecked():
|
||||
options.smartcovercrop = True
|
||||
if GUI.noSmartCoverCropBox.isChecked():
|
||||
options.nosmartcovercrop = True
|
||||
if GUI.coverFillBox.isChecked():
|
||||
options.coverfill = True
|
||||
if GUI.metadataTitleBox.checkState() == Qt.CheckState.PartiallyChecked:
|
||||
@@ -948,7 +948,6 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
|
||||
GUI.chunkSizeCheckBox.setChecked(False)
|
||||
elif GUI.formats[str(GUI.formatBox.currentText())]['format'] == 'KFX':
|
||||
GUI.mozJpegBox.setCheckState(Qt.CheckState.PartiallyChecked)
|
||||
GUI.upscaleBox.setChecked(True)
|
||||
elif not GUI.webtoonBox.isChecked():
|
||||
GUI.chunkSizeCheckBox.setEnabled(True)
|
||||
if GUI.formats[str(GUI.formatBox.currentText())]['format'] in ('CBZ', 'PDF') and not GUI.webtoonBox.isChecked():
|
||||
@@ -1085,7 +1084,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
|
||||
'disableProcessingBox': GUI.disableProcessingBox.checkState(),
|
||||
'pdfExtractBox': GUI.pdfExtractBox.checkState(),
|
||||
'pdfWidthBox': GUI.pdfWidthBox.checkState(),
|
||||
'smartCoverCropBox': GUI.smartCoverCropBox.checkState(),
|
||||
'noSmartCoverCropBox': GUI.noSmartCoverCropBox.checkState(),
|
||||
'coverFillBox': GUI.coverFillBox.checkState(),
|
||||
'metadataTitleBox': GUI.metadataTitleBox.checkState(),
|
||||
'mozJpegBox': GUI.mozJpegBox.checkState(),
|
||||
@@ -1262,9 +1261,6 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
|
||||
"Kindle 1240x1860": {
|
||||
'PVOptions': True, 'ForceExpert': False, 'DefaultFormat': 0, 'DefaultUpscale': False, 'ForceColor': False, 'Label': 'KS1240',
|
||||
},
|
||||
"Kindle 1324x1986": {
|
||||
'PVOptions': True, 'ForceExpert': False, 'DefaultFormat': 0, 'DefaultUpscale': False, 'ForceColor': False, 'Label': 'KS1324',
|
||||
},
|
||||
"Kindle Scribe 1/2": {
|
||||
'PVOptions': True, 'ForceExpert': False, 'DefaultFormat': 0, 'DefaultUpscale': False, 'ForceColor': False, 'Label': 'KS',
|
||||
},
|
||||
@@ -1372,7 +1368,6 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
|
||||
"Separator",
|
||||
"Other",
|
||||
"Separator",
|
||||
"Kindle 1324x1986",
|
||||
"Kindle 1920x1920",
|
||||
"Kindle 1860x1920",
|
||||
"Kindle 1240x1860",
|
||||
|
||||
@@ -344,10 +344,10 @@ class Ui_mainWindow(object):
|
||||
|
||||
self.gridLayout_2.addWidget(self.metadataTitleBox, 7, 0, 1, 1)
|
||||
|
||||
self.smartCoverCropBox = QCheckBox(self.optionWidget)
|
||||
self.smartCoverCropBox.setObjectName(u"smartCoverCropBox")
|
||||
self.noSmartCoverCropBox = QCheckBox(self.optionWidget)
|
||||
self.noSmartCoverCropBox.setObjectName(u"noSmartCoverCropBox")
|
||||
|
||||
self.gridLayout_2.addWidget(self.smartCoverCropBox, 11, 1, 1, 1)
|
||||
self.gridLayout_2.addWidget(self.noSmartCoverCropBox, 11, 1, 1, 1)
|
||||
|
||||
self.rotateFirstBox = QCheckBox(self.optionWidget)
|
||||
self.rotateFirstBox.setObjectName(u"rotateFirstBox")
|
||||
@@ -753,9 +753,9 @@ class Ui_mainWindow(object):
|
||||
#endif // QT_CONFIG(tooltip)
|
||||
self.metadataTitleBox.setText(QCoreApplication.translate("mainWindow", u"Metadata Title", None))
|
||||
#if QT_CONFIG(tooltip)
|
||||
self.smartCoverCropBox.setToolTip(QCoreApplication.translate("mainWindow", u"<html><head/><body><p>Attempt to crop main cover from wide image.</p></body></html>", None))
|
||||
self.noSmartCoverCropBox.setToolTip(QCoreApplication.translate("mainWindow", u"Disable 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.noSmartCoverCropBox.setText(QCoreApplication.translate("mainWindow", u"No Smart Cover Crop", None))
|
||||
#if QT_CONFIG(tooltip)
|
||||
self.rotateFirstBox.setToolTip(QCoreApplication.translate("mainWindow", u"<html><head/><body><p>When the spread splitter option is partially checked,</p><p><span style=\" font-weight:600; text-decoration: underline;\">Unchecked - Rotate Last<br/></span>Put the rotated 2 page spread after the split spreads.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Checked - Rotate First<br/></span>Put the rotated 2 page spread before the split spreads.</p></body></html>", None))
|
||||
#endif // QT_CONFIG(tooltip)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
__version__ = '10.1.3'
|
||||
__version__ = '10.1.0'
|
||||
__license__ = 'ISC'
|
||||
__copyright__ = '2012-2022, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>, darodi'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
@@ -144,7 +144,7 @@ def buildHTML(path, imgfile, imgfilepath, imgfile2=None):
|
||||
f.write('<div style="display:none;">.</div>\n')
|
||||
f.write(f'<img width="{imgsize[0]}" height="{imgsize[1]}" src="{"../" * backref}Images/{postfix}{imgfile}"/>\n')
|
||||
if imgfile2:
|
||||
f.write(f'<img style="top: 1920px" width="{imgsize2[0]}" height="{imgsize2[1]}" src="{"../" * backref}Images/{postfix}{imgfile2}"/>\n')
|
||||
f.write(f'<img style="bottom: 0" width="{imgsize2[0]}" height="{imgsize2[1]}" src="{"../" * backref}Images/{postfix}{imgfile2}"/>\n')
|
||||
f.write("</div>\n")
|
||||
if options.iskindle and options.panelview:
|
||||
if options.autoscale:
|
||||
@@ -1406,8 +1406,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("--nosmartcovercrop", action="store_true", dest="nosmartcovercrop", default=False,
|
||||
help="Disable 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,
|
||||
@@ -1706,27 +1706,27 @@ def makeBook(source, qtgui=None, job_progress=''):
|
||||
size = get_contain_resolution(imagef, (x, y))
|
||||
normalized_resolutions.append(size)
|
||||
|
||||
counter = Counter(normalized_resolutions)
|
||||
counter = Counter(normalized_resolutions)
|
||||
|
||||
aspect_ratios = []
|
||||
filtered_resolutions = []
|
||||
for w, h in normalized_resolutions:
|
||||
aspect_ratio = h / w
|
||||
# page-like aspect ratios, could be improved
|
||||
if aspect_ratio > 1.3 and aspect_ratio < 1.7:
|
||||
aspect_ratios.append(aspect_ratio)
|
||||
filtered_resolutions.append((w, h))
|
||||
aspect_ratios = []
|
||||
filtered_resolutions = []
|
||||
for w, h in normalized_resolutions:
|
||||
aspect_ratio = h / w
|
||||
# page-like aspect ratios, could be improved
|
||||
if aspect_ratio > 1.3 and aspect_ratio < 1.7:
|
||||
aspect_ratios.append(aspect_ratio)
|
||||
filtered_resolutions.append((w, h))
|
||||
|
||||
most_common_res, most_common_count = counter.most_common(1)[0]
|
||||
options.kfx_resolution = most_common_res
|
||||
if most_common_count / sum(counter.values()) > .6:
|
||||
pass
|
||||
#elif max(aspect_ratios) - min(aspect_ratios) < .2:
|
||||
else:
|
||||
# get the widest resolution
|
||||
options.kfx_resolution = max(filtered_resolutions)
|
||||
# else:
|
||||
# raise UserWarning('Aspect ratio of pages too different for KFX conversion')
|
||||
most_common_res, most_common_count = counter.most_common(1)[0]
|
||||
options.kfx_resolution = most_common_res
|
||||
if most_common_count / counter.total() > .6:
|
||||
pass
|
||||
#elif max(aspect_ratios) - min(aspect_ratios) < .2:
|
||||
else:
|
||||
# get the widest resolution
|
||||
options.kfx_resolution = max(filtered_resolutions)
|
||||
# else:
|
||||
# raise UserWarning('Aspect ratio of pages too different for KFX conversion')
|
||||
|
||||
if options.noprocessing:
|
||||
print(f"{job_progress}Do not process image, ignore any profile or processing option")
|
||||
|
||||
@@ -106,7 +106,6 @@ class ProfileData:
|
||||
'KS1860': ("Kindle 1860", (1860, 1920), Palette16, 1.0),
|
||||
'KS1920': ("Kindle 1920", (1920, 1920), Palette16, 1.0),
|
||||
'KS1240': ("Kindle 1240", (1240, 1860), Palette16, 1.0),
|
||||
'KS1324': ("Kindle 1324", (1324, 1986), Palette16, 1.0),
|
||||
'KS': ("Kindle Scribe 1/2", (1860, 2480), Palette16, 1.0),
|
||||
'KCS': ("Kindle Colorsoft", (1272, 1696), Palette16, 1.0),
|
||||
'KS3': ("Kindle Scribe 3", (1986, 2648), Palette16, 1.0),
|
||||
@@ -599,7 +598,7 @@ class Cover:
|
||||
self.image = ImageOps.autocontrast(self.image, preserve_tone=True)
|
||||
if not self.options.forcecolor:
|
||||
self.image = self.image.convert('L')
|
||||
if self.options.smartcovercrop:
|
||||
if not self.options.nosmartcovercrop:
|
||||
self.crop_main_cover()
|
||||
|
||||
size = list(self.options.profileData[1])
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Pillow>=11.3.0
|
||||
psutil>=5.9.5
|
||||
requests>=2.31.0
|
||||
python-slugify>=1.2.1
|
||||
python-slugify>=8.0.4
|
||||
packaging>=23.2
|
||||
mozjpeg-lossless-optimization>=1.2.0
|
||||
natsort>=8.4.0
|
||||
|
||||
@@ -2,7 +2,7 @@ PySide6==6.4.3
|
||||
Pillow>=11.3.0
|
||||
psutil>=5.9.5
|
||||
requests>=2.31.0
|
||||
python-slugify>=1.2.1
|
||||
python-slugify>=8.0.4
|
||||
raven>=6.0.0
|
||||
packaging>=23.2
|
||||
mozjpeg-lossless-optimization>=1.2.0
|
||||
|
||||
@@ -2,7 +2,7 @@ PySide6==6.1.3
|
||||
Pillow>=9
|
||||
psutil>=5.9.5
|
||||
requests>=2.31.0
|
||||
python-slugify>=1.2.1
|
||||
python-slugify>=8.0.4
|
||||
raven>=6.0.0
|
||||
packaging>=23.2
|
||||
mozjpeg-lossless-optimization>=1.2.0
|
||||
|
||||
@@ -2,7 +2,7 @@ PySide6<6.10
|
||||
Pillow>=11.3.0
|
||||
psutil>=5.9.5
|
||||
requests>=2.31.0
|
||||
python-slugify>=1.2.1,<9.0.0
|
||||
python-slugify>=8.0.4,<9.0.0
|
||||
raven>=6.0.0
|
||||
packaging>=23.2
|
||||
mozjpeg-lossless-optimization>=1.2.0
|
||||
|
||||
Reference in New Issue
Block a user