mirror of
https://github.com/ciromattia/kcc
synced 2026-09-21 18:27:08 +00:00
add wallpaper mode for KOreader (#1431)
* add wallpaper mode for KOreader * fix wallpaper interactions with no rotate
This commit is contained in:
@@ -287,6 +287,7 @@ PROCESSING:
|
|||||||
--pdfwidth Render vector PDFs based on device width instead of height.
|
--pdfwidth Render vector PDFs based on device width instead of height.
|
||||||
-u, --upscale Resize images smaller than device's resolution
|
-u, --upscale Resize images smaller than device's resolution
|
||||||
-s, --stretch Stretch images to device's resolution
|
-s, --stretch Stretch images to device's resolution
|
||||||
|
--wallpaper Crop images to to fill screen
|
||||||
-r SPLITTER, --splitter SPLITTER
|
-r SPLITTER, --splitter SPLITTER
|
||||||
Double page parsing mode. 0: Split 1: Rotate 2: Both [Default=0]
|
Double page parsing mode. 0: Split 1: Rotate 2: Both [Default=0]
|
||||||
-g GAMMA, --gamma GAMMA
|
-g GAMMA, --gamma GAMMA
|
||||||
|
|||||||
+12
@@ -693,6 +693,18 @@ Keeping this file may crash some readers like the Kobo native CBZ reader.</strin
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="11" column="0">
|
||||||
|
<widget class="QCheckBox" name="wallpaperBox">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Auto check various options intended for KOreader wallpapers.
|
||||||
|
|
||||||
|
Will also crop images to fill the screen centered.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Wallpaper mode</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -253,6 +253,8 @@ def get_options():
|
|||||||
options.righttoleft = True
|
options.righttoleft = True
|
||||||
if GUI.lightnovelBox.isChecked():
|
if GUI.lightnovelBox.isChecked():
|
||||||
options.lightnovel = True
|
options.lightnovel = True
|
||||||
|
if GUI.wallpaperBox.isChecked():
|
||||||
|
options.wallpaper = True
|
||||||
if GUI.ebokBox.isChecked():
|
if GUI.ebokBox.isChecked():
|
||||||
options.ebok = True
|
options.ebok = True
|
||||||
if GUI.invertDirectionBox.isChecked():
|
if GUI.invertDirectionBox.isChecked():
|
||||||
@@ -969,6 +971,14 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
|
|||||||
GUI.noQuantizeBox.setEnabled(False)
|
GUI.noQuantizeBox.setEnabled(False)
|
||||||
GUI.forcePngRgbBox.setEnabled(False)
|
GUI.forcePngRgbBox.setEnabled(False)
|
||||||
|
|
||||||
|
def toggleWallpaperBox(self, value):
|
||||||
|
if value == 2:
|
||||||
|
GUI.mozJpegBox.setCheckState(Qt.CheckState.PartiallyChecked)
|
||||||
|
GUI.pngLegacyBox.setChecked(True)
|
||||||
|
GUI.rotateBox.setChecked(True)
|
||||||
|
GUI.noRotateBox.setChecked(True)
|
||||||
|
GUI.upscaleBox.setChecked(True)
|
||||||
|
self.changeFormat(3)
|
||||||
|
|
||||||
def togglechunkSizeCheckBox(self, value):
|
def togglechunkSizeCheckBox(self, value):
|
||||||
GUI.chunkSizeWidget.setVisible(value)
|
GUI.chunkSizeWidget.setVisible(value)
|
||||||
@@ -1071,6 +1081,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
|
|||||||
if GUI.formats[str(GUI.formatBox.currentText())]['format'] in ('CBZ', 'FOLDER', 'PDF') and not GUI.webtoonBox.isChecked():
|
if GUI.formats[str(GUI.formatBox.currentText())]['format'] in ('CBZ', 'FOLDER', 'PDF') and not GUI.webtoonBox.isChecked():
|
||||||
self.addMessage("Partially check W/B Margins if you don't want KCC to extend the image margins.", 'info')
|
self.addMessage("Partially check W/B Margins if you don't want KCC to extend the image margins.", 'info')
|
||||||
GUI.borderBox.setCheckState(Qt.CheckState.PartiallyChecked)
|
GUI.borderBox.setCheckState(Qt.CheckState.PartiallyChecked)
|
||||||
|
GUI.mozJpegBox.setCheckState(Qt.CheckState.PartiallyChecked)
|
||||||
else:
|
else:
|
||||||
GUI.borderBox.setCheckState(Qt.CheckState.Unchecked)
|
GUI.borderBox.setCheckState(Qt.CheckState.Unchecked)
|
||||||
|
|
||||||
@@ -1185,6 +1196,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
|
|||||||
self.settings.setValue('windowSize', str(MW.size().width()) + 'x' + str(MW.size().height()))
|
self.settings.setValue('windowSize', str(MW.size().width()) + 'x' + str(MW.size().height()))
|
||||||
self.settings.setValue('options', {'mangaBox': GUI.mangaBox.checkState(),
|
self.settings.setValue('options', {'mangaBox': GUI.mangaBox.checkState(),
|
||||||
'lightnovelBox': GUI.lightnovelBox.checkState(),
|
'lightnovelBox': GUI.lightnovelBox.checkState(),
|
||||||
|
'wallpaperBox': GUI.wallpaperBox.checkState(),
|
||||||
'ebokBox': GUI.ebokBox.checkState(),
|
'ebokBox': GUI.ebokBox.checkState(),
|
||||||
'invertDirectionBox': GUI.invertDirectionBox.checkState(),
|
'invertDirectionBox': GUI.invertDirectionBox.checkState(),
|
||||||
'languageEdit': GUI.languageEdit.text(),
|
'languageEdit': GUI.languageEdit.text(),
|
||||||
@@ -1582,6 +1594,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
|
|||||||
GUI.webtoonBox.stateChanged.connect(self.togglewebtoonBox)
|
GUI.webtoonBox.stateChanged.connect(self.togglewebtoonBox)
|
||||||
GUI.qualityBox.stateChanged.connect(self.togglequalityBox)
|
GUI.qualityBox.stateChanged.connect(self.togglequalityBox)
|
||||||
GUI.mozJpegBox.stateChanged.connect(self.toggleImageFormatBox)
|
GUI.mozJpegBox.stateChanged.connect(self.toggleImageFormatBox)
|
||||||
|
GUI.wallpaperBox.stateChanged.connect(self.toggleWallpaperBox)
|
||||||
GUI.chunkSizeCheckBox.stateChanged.connect(self.togglechunkSizeCheckBox)
|
GUI.chunkSizeCheckBox.stateChanged.connect(self.togglechunkSizeCheckBox)
|
||||||
GUI.deviceBox.activated.connect(self.changeDevice)
|
GUI.deviceBox.activated.connect(self.changeDevice)
|
||||||
GUI.formatBox.activated.connect(self.changeFormat)
|
GUI.formatBox.activated.connect(self.changeFormat)
|
||||||
|
|||||||
@@ -352,6 +352,11 @@ class Ui_mainWindow(object):
|
|||||||
|
|
||||||
self.gridLayout_2.addWidget(self.keepComicInfoBox, 11, 3, 1, 1)
|
self.gridLayout_2.addWidget(self.keepComicInfoBox, 11, 3, 1, 1)
|
||||||
|
|
||||||
|
self.wallpaperBox = QCheckBox(self.optionWidget)
|
||||||
|
self.wallpaperBox.setObjectName(u"wallpaperBox")
|
||||||
|
|
||||||
|
self.gridLayout_2.addWidget(self.wallpaperBox, 11, 0, 1, 1)
|
||||||
|
|
||||||
|
|
||||||
self.gridLayout.addWidget(self.optionWidget, 5, 0, 1, 2)
|
self.gridLayout.addWidget(self.optionWidget, 5, 0, 1, 2)
|
||||||
|
|
||||||
@@ -854,6 +859,12 @@ class Ui_mainWindow(object):
|
|||||||
"Keeping this file may crash some readers like the Kobo native CBZ reader.", None))
|
"Keeping this file may crash some readers like the Kobo native CBZ reader.", None))
|
||||||
#endif // QT_CONFIG(tooltip)
|
#endif // QT_CONFIG(tooltip)
|
||||||
self.keepComicInfoBox.setText(QCoreApplication.translate("mainWindow", u"Keep ComicInfo.xml", None))
|
self.keepComicInfoBox.setText(QCoreApplication.translate("mainWindow", u"Keep ComicInfo.xml", None))
|
||||||
|
#if QT_CONFIG(tooltip)
|
||||||
|
self.wallpaperBox.setToolTip(QCoreApplication.translate("mainWindow", u"Auto check various options intended for KOreader wallpapers.\n"
|
||||||
|
"\n"
|
||||||
|
"Will also crop images to fill the screen centered.", None))
|
||||||
|
#endif // QT_CONFIG(tooltip)
|
||||||
|
self.wallpaperBox.setText(QCoreApplication.translate("mainWindow", u"Wallpaper mode", None))
|
||||||
#if QT_CONFIG(tooltip)
|
#if QT_CONFIG(tooltip)
|
||||||
self.editorButton.setToolTip(QCoreApplication.translate("mainWindow", u"<html><head/><body><p style='white-space:pre'>Shift+Click to edit directory.</p></body></html>", None))
|
self.editorButton.setToolTip(QCoreApplication.translate("mainWindow", u"<html><head/><body><p style='white-space:pre'>Shift+Click to edit directory.</p></body></html>", None))
|
||||||
#endif // QT_CONFIG(tooltip)
|
#endif // QT_CONFIG(tooltip)
|
||||||
|
|||||||
@@ -1058,7 +1058,7 @@ def getWorkFolder(afile, options, workdir=None):
|
|||||||
|
|
||||||
|
|
||||||
def getOutputFilename(srcpath, wantedname, ext, tomenumber):
|
def getOutputFilename(srcpath, wantedname, ext, tomenumber):
|
||||||
if options.format == 'CBZ' and options.skip_zip:
|
if options.folder_output:
|
||||||
ext = ''
|
ext = ''
|
||||||
source_path = Path(srcpath)
|
source_path = Path(srcpath)
|
||||||
if srcpath[-1] == os.path.sep:
|
if srcpath[-1] == os.path.sep:
|
||||||
@@ -1071,7 +1071,7 @@ def getOutputFilename(srcpath, wantedname, ext, tomenumber):
|
|||||||
ext = '.kepub.epub'
|
ext = '.kepub.epub'
|
||||||
if wantedname is not None:
|
if wantedname is not None:
|
||||||
wanted_root, wanted_ext = os.path.splitext(wantedname)
|
wanted_root, wanted_ext = os.path.splitext(wantedname)
|
||||||
if wantedname.endswith(ext):
|
if not options.folder_output and wantedname.endswith(ext):
|
||||||
filename = os.path.abspath(wantedname)
|
filename = os.path.abspath(wantedname)
|
||||||
elif wanted_ext == '.mobi' and ext == '.epub':
|
elif wanted_ext == '.mobi' and ext == '.epub':
|
||||||
filename = os.path.abspath(wanted_root + ext)
|
filename = os.path.abspath(wanted_root + ext)
|
||||||
@@ -1432,8 +1432,8 @@ def slugify(value, options, is_natural_sorted):
|
|||||||
return value
|
return value
|
||||||
|
|
||||||
def makeZIP(zipfilename, basedir, job_progress='', isepub=False):
|
def makeZIP(zipfilename, basedir, job_progress='', isepub=False):
|
||||||
if options.format == 'CBZ' and options.skip_zip:
|
if options.folder_output:
|
||||||
os.rename(basedir, zipfilename)
|
move(basedir, zipfilename)
|
||||||
return zipfilename
|
return zipfilename
|
||||||
start = perf_counter()
|
start = perf_counter()
|
||||||
if SEVENZIP in available_archive_tools():
|
if SEVENZIP in available_archive_tools():
|
||||||
@@ -1480,6 +1480,8 @@ def makeParser():
|
|||||||
help="Manga style (right-to-left reading and splitting)")
|
help="Manga style (right-to-left reading and splitting)")
|
||||||
main_options.add_argument("--lightnovel", action="store_true", dest="lightnovel", default=False,
|
main_options.add_argument("--lightnovel", action="store_true", dest="lightnovel", default=False,
|
||||||
help="Only resize images and preserve original file structure.")
|
help="Only resize images and preserve original file structure.")
|
||||||
|
main_options.add_argument("--wallpaper", action="store_true", dest="wallpaper", default=False,
|
||||||
|
help="Crop to fill screen.")
|
||||||
main_options.add_argument("--ebok", action="store_true", dest="ebok", default=False,
|
main_options.add_argument("--ebok", action="store_true", dest="ebok", default=False,
|
||||||
help="Force EBOK tag instead of PDOC for MOBI")
|
help="Force EBOK tag instead of PDOC for MOBI")
|
||||||
main_options.add_argument("--invertdirection", action="store_true", dest="invertdirection", default=False,
|
main_options.add_argument("--invertdirection", action="store_true", dest="invertdirection", default=False,
|
||||||
@@ -1645,9 +1647,11 @@ def checkOptions(options):
|
|||||||
options.format = 'MOBI'
|
options.format = 'MOBI'
|
||||||
options.kfx = False
|
options.kfx = False
|
||||||
options.skip_zip = False
|
options.skip_zip = False
|
||||||
|
options.folder_output = False
|
||||||
if options.format == 'FOLDER':
|
if options.format == 'FOLDER':
|
||||||
options.format = 'CBZ'
|
options.format = 'CBZ'
|
||||||
options.skip_zip = True
|
options.skip_zip = True
|
||||||
|
options.folder_output = True
|
||||||
if options.format == 'Auto':
|
if options.format == 'Auto':
|
||||||
if options.profile in ['KDX']:
|
if options.profile in ['KDX']:
|
||||||
options.format = 'CBZ'
|
options.format = 'CBZ'
|
||||||
|
|||||||
@@ -513,7 +513,9 @@ class ComicPage:
|
|||||||
self.image = erase_rainbow_artifacts(self.image, is_color)
|
self.image = erase_rainbow_artifacts(self.image, is_color)
|
||||||
|
|
||||||
def resizeImage(self):
|
def resizeImage(self):
|
||||||
if self.opt.norotate and self.targetPathOrder in ('-kcc-a', '-kcc-d') and not self.opt.kindle_scribe_azw3:
|
if self.opt.wallpaper:
|
||||||
|
pass
|
||||||
|
elif self.opt.norotate and self.targetPathOrder in ('-kcc-a', '-kcc-d') and not self.opt.kindle_scribe_azw3:
|
||||||
# TODO: Kindle Scribe case
|
# TODO: Kindle Scribe case
|
||||||
if self.opt.kindle_azw3 and any(dim > 1920 for dim in self.image.size):
|
if self.opt.kindle_azw3 and any(dim > 1920 for dim in self.image.size):
|
||||||
self.image = ImageOps.contain(self.image, (1920, 1920), Image.Resampling.LANCZOS)
|
self.image = ImageOps.contain(self.image, (1920, 1920), Image.Resampling.LANCZOS)
|
||||||
@@ -536,6 +538,8 @@ class ComicPage:
|
|||||||
self.image = ImageOps.pad(self.image, self.opt.kfx_resolution, method=method, color=self.fill)
|
self.image = ImageOps.pad(self.image, self.opt.kfx_resolution, method=method, color=self.fill)
|
||||||
elif self.opt.stretch:
|
elif self.opt.stretch:
|
||||||
self.image = self.image.resize(self.size, method)
|
self.image = self.image.resize(self.size, method)
|
||||||
|
elif self.opt.wallpaper:
|
||||||
|
self.image = ImageOps.fit(self.image, self.size, method=method)
|
||||||
elif method == Image.Resampling.BICUBIC and not self.opt.upscale:
|
elif method == Image.Resampling.BICUBIC and not self.opt.upscale:
|
||||||
pass
|
pass
|
||||||
else: # if image bigger than device resolution or smaller with upscaling
|
else: # if image bigger than device resolution or smaller with upscaling
|
||||||
|
|||||||
Reference in New Issue
Block a user