mirror of
https://github.com/ciromattia/kcc
synced 2026-04-16 14:08:45 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d61a9e558 | ||
|
|
8aaedf274d | ||
|
|
5782a44e7b | ||
|
|
e4c918f0f3 | ||
|
|
8f4072bfab | ||
|
|
61f3097be5 | ||
|
|
fa33ef8f89 | ||
|
|
232bac00a9 | ||
|
|
d19a4754fa |
11
.github/workflows/package-windows7.yml
vendored
11
.github/workflows/package-windows7.yml
vendored
@@ -50,6 +50,17 @@ jobs:
|
||||
with:
|
||||
name: windows7-build
|
||||
path: dist/*.exe
|
||||
- id: optional_step_id
|
||||
uses: signpath/github-action-submit-signing-request@v2.0
|
||||
if: ${{ github.repository == 'ciromattia/kcc' }}
|
||||
with:
|
||||
api-token: '${{ secrets.SIGNPATH_API_TOKEN }}'
|
||||
organization-id: '1dc1bad6-4a8c-4f85-af30-5c5d3d392ea6'
|
||||
project-slug: 'kcc'
|
||||
signing-policy-slug: 'release-signing'
|
||||
github-artifact-id: '${{ steps.upload-unsigned-artifact.outputs.artifact-id }}'
|
||||
wait-for-completion: true
|
||||
output-artifact-directory: 'dist/'
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
|
||||
@@ -270,9 +270,11 @@ 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
|
||||
--webp Replace JPG with lossy WEBP and PNG with lossless WEBP
|
||||
--force-png-rgb Force color images to be saved as PNG
|
||||
--pnglegacy Use a more compatible 8 bit PNG instead of 4 bit.
|
||||
--noquantize Don't quantize PNG images to 16 colors
|
||||
|
||||
1516
gui/KCC.ui
1516
gui/KCC.ui
File diff suppressed because it is too large
Load Diff
@@ -195,7 +195,7 @@ class VersionThread(QThread):
|
||||
icon = 'bindle'
|
||||
if category == 'kofi':
|
||||
icon = 'kofi'
|
||||
message = f"<b>{payload.get('name')}</b>"
|
||||
message = f"{payload.get('name')}"
|
||||
if payload.get('link'):
|
||||
message = '<a href="{}"><b>{}</b></a>'.format(payload.get('link'), payload.get('name'))
|
||||
if payload.get('showDeadline'):
|
||||
@@ -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:
|
||||
@@ -357,6 +359,8 @@ class WorkerThread(QThread):
|
||||
options.forcepng = True
|
||||
elif GUI.mozJpegBox.checkState() == Qt.CheckState.Checked:
|
||||
options.mozjpeg = True
|
||||
if GUI.webpBox.isChecked():
|
||||
options.webp = True
|
||||
if GUI.pngLegacyBox.isChecked():
|
||||
options.pnglegacy = True
|
||||
if GUI.noQuantizeBox.isChecked():
|
||||
@@ -692,6 +696,18 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
|
||||
# noinspection PyCallByClass
|
||||
QDesktopServices.openUrl(QUrl('https://ko-fi.com/eink_dude'))
|
||||
|
||||
def openHumble(self):
|
||||
# noinspection PyCallByClass
|
||||
QDesktopServices.openUrl(QUrl('https://humblebundleinc.sjv.io/3JaR3A'))
|
||||
|
||||
def openYouTube(self):
|
||||
# noinspection PyCallByClass
|
||||
QDesktopServices.openUrl(QUrl('https://www.youtube.com/@eink-dude'))
|
||||
|
||||
def openDiscord(self):
|
||||
# noinspection PyCallByClass
|
||||
QDesktopServices.openUrl(QUrl('https://discord.gg/um5JRKwmGT'))
|
||||
|
||||
def modeChange(self, mode):
|
||||
if mode == 1:
|
||||
self.currentMode = 1
|
||||
@@ -826,6 +842,14 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
|
||||
if bad_format in current_format:
|
||||
self.addMessage('Scribe PNG MOBI/EPUB has a lot of problems like blank pages/sections. Use JPG instead.', 'warning')
|
||||
break
|
||||
GUI.pngLegacyBox.setEnabled(True)
|
||||
GUI.noQuantizeBox.setEnabled(True)
|
||||
GUI.forcePngRgbBox.setEnabled(True)
|
||||
else:
|
||||
GUI.pngLegacyBox.setEnabled(False)
|
||||
GUI.noQuantizeBox.setEnabled(False)
|
||||
GUI.forcePngRgbBox.setEnabled(False)
|
||||
|
||||
|
||||
def togglechunkSizeCheckBox(self, value):
|
||||
GUI.chunkSizeWidget.setVisible(value)
|
||||
@@ -1053,10 +1077,12 @@ 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(),
|
||||
'forcePngRgbBox': GUI.forcePngRgbBox.checkState(),
|
||||
'webpBox': GUI.webpBox.checkState(),
|
||||
'pngLegacyBox': GUI.pngLegacyBox.checkState(),
|
||||
'noQuantizeBox': GUI.noQuantizeBox.checkState(),
|
||||
'jpegQualityBox': GUI.jpegQualityBox.checkState(),
|
||||
@@ -1191,7 +1217,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
|
||||
'convertButton', 'formatBox']:
|
||||
getattr(GUI, element).setMinimumSize(QSize(0, 0))
|
||||
GUI.gridLayout.setContentsMargins(-1, -1, -1, -1)
|
||||
for element in ['gridLayout_2', 'gridLayout_3', 'gridLayout_4', 'horizontalLayout', 'horizontalLayout_2']:
|
||||
for element in ['gridLayout_2', 'gridLayout_3', 'gridLayout_4', 'gridLayout_6', 'horizontalLayout_2']:
|
||||
getattr(GUI, element).setContentsMargins(-1, 0, -1, 0)
|
||||
if self.windowSize == '0x0':
|
||||
MW.resize(500, 500)
|
||||
@@ -1399,6 +1425,9 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
|
||||
GUI.editorButton.clicked.connect(self.selectFileMetaEditor)
|
||||
GUI.wikiButton.clicked.connect(self.openWiki)
|
||||
GUI.kofiButton.clicked.connect(self.openKofi)
|
||||
GUI.humbleButton.clicked.connect(self.openHumble)
|
||||
GUI.youtubeButton.clicked.connect(self.openYouTube)
|
||||
GUI.discordButton.clicked.connect(self.openDiscord)
|
||||
GUI.convertButton.clicked.connect(self.convertStart)
|
||||
GUI.gammaSlider.valueChanged.connect(self.changeGamma)
|
||||
GUI.gammaBox.stateChanged.connect(self.togglegammaBox)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
__version__ = '9.6.2'
|
||||
__version__ = '9.7.0'
|
||||
__license__ = 'ISC'
|
||||
__copyright__ = '2012-2022, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>, darodi'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
@@ -353,6 +353,8 @@ def buildOPF(dstdir, title, filelist, originalpath, cover=None):
|
||||
mt = 'image/png'
|
||||
elif '.gif' == filename[1]:
|
||||
mt = 'image/gif'
|
||||
elif '.webp' == filename[1]:
|
||||
mt = 'image/webp'
|
||||
else:
|
||||
mt = 'image/jpeg'
|
||||
f.write("<item id=\"img_" + str(uniqueid) + "\" href=\"" + folder + "/" + path[1] + "\" media-type=\"" +
|
||||
@@ -893,9 +895,11 @@ def getWorkFolder(afile, workdir=None):
|
||||
return workdir
|
||||
target_width, target_height = options.profileData[1]
|
||||
if options.cropping == 1:
|
||||
target_height = target_height + target_height*0.20 #Account for possible margin at the top and bottom
|
||||
target_height *= 1.2 #Account for possible margin at the top and bottom
|
||||
target_width *= 1.2
|
||||
elif options.cropping == 2:
|
||||
target_height = target_height + target_height*0.25 #Account for possible margin at the top and bottom with page number
|
||||
target_height *= 1.25 #Account for possible margin at the top and bottom with page number
|
||||
target_width *= 1.25
|
||||
try:
|
||||
mupdf_pdf_process_pages_parallel(afile, fullPath, target_width, target_height)
|
||||
except Exception as e:
|
||||
@@ -1295,12 +1299,12 @@ def makeZIP(zipfilename, basedir, job_progress='', isepub=False):
|
||||
mimetypeFile = open(os.path.join(basedir, '!mimetype'), 'w')
|
||||
mimetypeFile.write('application/epub+zip')
|
||||
mimetypeFile.close()
|
||||
subprocess_run([SEVENZIP, 'a', '-tzip', zipfilename, "*"], capture_output=True, check=True, cwd=basedir)
|
||||
subprocess_run([SEVENZIP, 'a', '-mx0', '-tzip', zipfilename, "*"], capture_output=True, check=True, cwd=basedir)
|
||||
# crazy hack to ensure mimetype is first when using 7zip
|
||||
if isepub:
|
||||
subprocess_run([SEVENZIP, 'rn', zipfilename, '!mimetype', 'mimetype'], capture_output=True, check=True, cwd=basedir)
|
||||
else:
|
||||
zipOutput = ZipFile(zipfilename, 'w', ZIP_DEFLATED)
|
||||
zipOutput = ZipFile(zipfilename, 'w', ZIP_STORED)
|
||||
if isepub:
|
||||
zipOutput.writestr('mimetype', 'application/epub+zip', ZIP_STORED)
|
||||
for dirpath, _, filenames in os.walk(basedir):
|
||||
@@ -1374,6 +1378,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,
|
||||
@@ -1414,6 +1420,8 @@ def makeParser():
|
||||
help="Create PNG files instead JPEG for black and white images")
|
||||
processing_options.add_argument("--force-png-rgb", action="store_true", dest="force_png_rgb", default=False,
|
||||
help="Force color images to be saved as PNG")
|
||||
processing_options.add_argument("--webp", action="store_true", dest="webp", default=False,
|
||||
help="Replace JPG with lossy WEBP and PNG with lossless WEBP")
|
||||
processing_options.add_argument("--pnglegacy", action="store_true", dest="pnglegacy", default=False,
|
||||
help="Use a more compatible 8 bit png instead of 4 bit")
|
||||
processing_options.add_argument("--noquantize", action="store_true", dest="noquantize", default=False,
|
||||
@@ -1533,6 +1541,8 @@ def checkOptions(options):
|
||||
options.kindle_azw3 = options.iskindle and ('MOBI' in options.format or 'EPUB' in options.format)
|
||||
options.kindle_scribe_azw3 = options.profile.startswith('KS') and options.kindle_azw3
|
||||
|
||||
options.webp_output = options.format != 'PDF' and not options.kindle_azw3 and options.webp
|
||||
|
||||
# CBZ files on Kindle DX/DXG support higher resolution
|
||||
if options.profile == 'KDX' and options.format == 'CBZ':
|
||||
options.profileData = list(image.ProfileData.Profiles[options.profile])
|
||||
|
||||
@@ -408,15 +408,21 @@ class ComicPage:
|
||||
def save_with_codec(self, image, targetPath):
|
||||
if self.opt.forcepng and (not self.colorOutput or self.opt.force_png_rgb):
|
||||
image.info.pop('transparency', None)
|
||||
if self.opt.iskindle and ('MOBI' in self.opt.format or 'EPUB' in self.opt.format):
|
||||
if self.opt.webp_output:
|
||||
targetPath += '.webp'
|
||||
image.save(targetPath, 'WEBP', lossless=True, quality=self.opt.jpegquality)
|
||||
elif self.opt.kindle_azw3:
|
||||
targetPath += '.gif'
|
||||
image.save(targetPath, 'GIF', optimize=1, interlace=False)
|
||||
else:
|
||||
targetPath += '.png'
|
||||
image.save(targetPath, 'PNG', optimize=1)
|
||||
else:
|
||||
targetPath += '.jpg'
|
||||
if self.opt.mozjpeg:
|
||||
if self.opt.webp_output:
|
||||
targetPath += '.webp'
|
||||
image.save(targetPath, 'WEBP', quality=self.opt.jpegquality)
|
||||
elif self.opt.mozjpeg:
|
||||
targetPath += '.jpg'
|
||||
with io.BytesIO() as output:
|
||||
image.save(output, format="JPEG", optimize=1, quality=self.opt.jpegquality)
|
||||
input_jpeg_bytes = output.getvalue()
|
||||
@@ -424,6 +430,7 @@ class ComicPage:
|
||||
with open(targetPath, "wb") as output_jpeg_file:
|
||||
output_jpeg_file.write(output_jpeg_bytes)
|
||||
else:
|
||||
targetPath += '.jpg'
|
||||
image.save(targetPath, 'JPEG', optimize=1, quality=self.opt.jpegquality)
|
||||
return targetPath
|
||||
|
||||
@@ -572,7 +579,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:
|
||||
|
||||
Reference in New Issue
Block a user