Compare commits

..
30 Commits
Author SHA1 Message Date
Alex Xu 66c6b8611a bump to 11.1.0 2026-09-03 23:06:40 -07:00
dependabot[bot]andpublic 1b3b619491 Bump signpath/github-action-submit-signing-request from 2.2 to 2.3 (#1418)
Bumps [signpath/github-action-submit-signing-request](https://github.com/signpath/github-action-submit-signing-request) from 2.2 to 2.3.
- [Release notes](https://github.com/signpath/github-action-submit-signing-request/releases)
- [Commits](https://github.com/signpath/github-action-submit-signing-request/compare/v2.2...v2.3)

---
updated-dependencies:
- dependency-name: signpath/github-action-submit-signing-request
  dependency-version: '2.3'
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-03 21:59:40 -07:00
dependabot[bot]andpublic fb784a2eb4 Bump actions/setup-node from 6 to 7 (#1401)
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 6 to 7.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-03 21:57:10 -07:00
dependabot[bot]andpublic f2deb1061f Bump actions/setup-python from 6 to 7 (#1408)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 6 to 7.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-03 21:56:56 -07:00
Alex Xu 3be76ec89f add legacy extract warning (#1433) 2026-09-03 21:52:27 -07:00
Alex Xu 38fa13610f A "Covers" folder next to source files defines custom covers (#1432)
* A "Covers" folder next to source files defines custom covers

* fix case with output folder unchecked
2026-09-03 15:00:07 -07:00
Alex Xu 6d3bd0296c add folder output to readme 2026-09-03 10:31:36 -07:00
Alex Xu 9decf0e68e add wallpaper mode for KOreader (#1431)
* add wallpaper mode for KOreader

* fix wallpaper interactions with no rotate
2026-09-03 10:21:08 -07:00
Alex Xu dc2cc8e7b8 rename folder to folder of images 2026-09-02 19:49:13 -07:00
Alex Xu 55468019dd add folder output option (#1430) 2026-09-02 16:56:42 -07:00
Alex Xu 8f191e604b replace more images 2026-08-30 18:12:27 -07:00
Alex Xu 924f83d976 use smaller images 2026-08-30 18:09:30 -07:00
Alex Xu 52d52ff323 Update README.md 2026-08-29 16:21:41 -07:00
Alex Xu e93be5cf68 Add files via upload 2026-08-29 16:21:20 -07:00
Alex Xu 4cdbb4beef bump to 11.0.3 2026-08-28 14:52:42 -07:00
Alex Xu 2c9056c524 label spread preview default is high quality (#1429) 2026-08-28 14:46:18 -07:00
Alex Xu a503f54f9f Spread labels support left to right (#1428) 2026-08-28 14:38:22 -07:00
Alex Xu fc331d4e19 bump to 11.0.2 2026-08-26 13:05:44 -07:00
Alex Xu adac558aab shift click label spreads for HQ preview (#1427) 2026-08-26 13:05:14 -07:00
Alex Xu c8cf50da0a fix spread label when it's the first page (#1426) 2026-08-26 11:40:25 -07:00
Alex Xu f38f1c45b2 update README.md 2026-08-26 09:25:07 -07:00
Alex Xu bd0328a12f bump to 11.0.1 2026-08-02 10:47:25 -07:00
Alex Xu 846a755761 fix label feature on Windows (#1413) 2026-08-01 15:58:45 -07:00
Alex Xu ff80d275e6 bump to 11.0.0 2026-07-31 22:26:11 -07:00
Alex Xu b3e1d393b6 Manually label spreads button (#1412)
* initial commit

* initial commit 2

* json it

* UI labels

* basics

* add todo

* options to getWorkFolder

* refactor options

* refactor UI

* cleanup

* pdf fixed size

* remove comment

* finalized json creation

* fix help text

* finalized

* remove print

* add youtube
2026-07-31 22:25:41 -07:00
Alex Xu b4c71b3b91 pass options to slugify (#1411) 2026-07-29 17:06:52 -07:00
Alex Xu 7e412f12ae pass options to getWorkFolder (#1410) 2026-07-29 16:41:34 -07:00
Nils Leo 2076775d94 Create the destination dir before flattening a single-subfolder archive (#1405) 2026-07-23 22:43:16 -07:00
Alex Xu 59df22b62d add sort order note to readme 2026-07-20 15:06:12 -07:00
Alex Xu ff5edc5ce5 fix: Destination path... already exists (#1404) 2026-07-20 14:21:42 -07:00
29 changed files with 674 additions and 307 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ jobs:
steps:
- uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v6
uses: actions/setup-python@v7
with:
python-version: 3.11
cache: 'pip'
+2 -2
View File
@@ -32,7 +32,7 @@ jobs:
steps:
- uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v6
uses: actions/setup-python@v7
with:
python-version: 3.11
cache: 'pip'
@@ -71,7 +71,7 @@ jobs:
# apply provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- uses: actions/setup-node@v6
- uses: actions/setup-node@v7
with:
node-version: 16
- run: npm install -g appdmg
+1 -1
View File
@@ -43,7 +43,7 @@ jobs:
pip3 install --upgrade pip pyinstaller certifi
pip3 install --upgrade -r requirements-osx-legacy.txt
./gen_ui_files.sh
- uses: actions/setup-node@v6
- uses: actions/setup-node@v7
with:
node-version: 16
- run: npm install -g appdmg
+2 -2
View File
@@ -37,7 +37,7 @@ jobs:
steps:
- uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v6
uses: actions/setup-python@v7
with:
python-version: 3.11
cache: 'pip'
@@ -58,7 +58,7 @@ jobs:
name: windows-build-${{ matrix.entry }}
path: dist/*.exe
- id: optional_step_id
uses: signpath/github-action-submit-signing-request@v2.2
uses: signpath/github-action-submit-signing-request@v2.3
if: ${{ github.repository == 'ciromattia/kcc' }}
with:
api-token: '${{ secrets.SIGNPATH_API_TOKEN }}'
+2 -2
View File
@@ -29,7 +29,7 @@ jobs:
steps:
- uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v6
uses: actions/setup-python@v7
with:
python-version: 3.8
cache: 'pip'
@@ -51,7 +51,7 @@ jobs:
name: windows7-build
path: dist/*.exe
- id: optional_step_id
uses: signpath/github-action-submit-signing-request@v2.2
uses: signpath/github-action-submit-signing-request@v2.3
if: ${{ github.repository == 'ciromattia/kcc' }}
with:
api-token: '${{ secrets.SIGNPATH_API_TOKEN }}'
+63 -32
View File
@@ -1,4 +1,8 @@
<img src="header.jpg" alt="Header Image" width="400">
Most manga conversion methods for ereaders add margins. But KCC enables true fullscreen from top to bottom.
![header](images/header_margins720.jpeg)
(feat. Ya Boy Kongming! and Fire Force from a [Humble Bundle](https://humblebundleinc.sjv.io/xL6Zv1) PDF source.)
# KCC
@@ -11,53 +15,77 @@
like Kindle, Kobo, ReMarkable, and more.
Pages display in fullscreen without margins,
with proper fixed layout support.
Supported input formats include JPG/PNG image files in folders, archives like CBZ, or PDFs.
Supported output formats include MOBI/AZW3, EPUB, KEPUB, CBZ, and PDF.
KCC runs on Windows, macOS, and Linux.
Supported input formats include JPG/PNG image files in folders, archives like CBZ/EPUB, or PDF.
Supported output formats include MOBI/AZW3, EPUB, KEPUB, CBZ, PDF, and folders of images.
The absolute highest quality source files are DRM-free PDFs from [Humble Bundle](https://humblebundleinc.sjv.io/xL6Zv1)/Fanatical.
The PDFs are often x12000 resolution or better, while even the 10" Kindle Scribe is only x2480.
KCC's main goal is maximum image quality at significantly smaller file size. For example, KCC
1) can compress a 600 MB manga volume from Humble Bundle to 100 MB.
This is mostly accomplished by downscaling to the native resolution of your specific device.
This can also improve battery life, page turn speed, and general performance
on underpowered ereaders with small memory and storage capacities.
2) fixes black levels to avoid gray/faded blacks found in many Kindle Store manga
![black](images/black720.jpeg)
3) fixes [the rainbow effect on Kaleido 3 color eink](https://www.youtube.com/watch?v=Dw2HTJCGMhw) without blur:
![rainbow](images/rainbow720.jpeg)
4) can [semi-automatically detect 2-page spreads](https://www.youtube.com/watch?v=kfIX67f7Aqk) from pre-split single pages:
![before](images/spreadbefore720.jpeg)
You can view combined spreads either rotated or not:
![full](images/full720.jpeg)
You can view the split halves either before or after combined spreads:
![half](images/half720.jpeg)
## Demo
Just drop your input files into the KCC window, hit convert, and USB drop the output files onto your device's `documents` folder!
https://github.com/user-attachments/assets/da73d625-e082-482d-91a4-ae4765e96fd7
**WARNING**: Kindle Scribe 2025 support may not be possible. Does not work well currently.
Then all your usb loaded comic files will show up next to all your normal books in your ereader library!
**NEW**: PDF output is now supported for direct conversion to reMarkable devices!
When using a reMarkable profile (Rmk1, Rmk2, RmkPP), the format automatically defaults to PDF
for optimal compatibility with your device's native PDF reader.
The final result looks incredible on my 10" Kindle Scribe: https://www.youtube.com/watch?v=2CIHW2N9Enc
The absolute highest quality source files are print quality DRM-free PDFs from Kodansha/[Humble Bundle](https://humblebundleinc.sjv.io/xL6Zv1)/Fanatical,
which can be directly converted by KCC.
**WARNING**: Kindle Scribe 2025 MOBI support may have blank pages. Use PDF instead.
Its main feature is various optional image processing steps to look good on eink screens,
which have different requirements than normal LCD screens.
Combining that with downscaling to your specific device's screen resolution
can result in filesize reductions of hundreds of MB per volume with no visible quality loss on eink.
This can also improve battery life, page turn speed, and general performance
on underpowered ereaders with small memory and storage capacities.
The GUI looks like this, built in Qt6.
There are a lot of options, but most people only care about the ones checked below.
Hover over each option to see details in a tooltip.
KCC avoids many common formatting issues (some of which occur [even on the Kindle Store](https://github.com/ciromattia/kcc/wiki/Kindle-Store-bad-formatting)), such as:
1) faded black levels causing unneccessarily low contrast, which is hard to see and can cause eyestrain.
2) unneccessary margins at the bottom of the screen
3) Not utilizing the full 1860x2480 resolution of the 10" Kindle Scribe
4) incorrect page turn direction for manga that's read right to left
5) unaligned two page spreads in landscape, where pages are shifted over by 1
6) Removing without blur the rainbow effect on color eink Kaleido 3 due to manga screentones
![settings](images/settings.png)
The GUI looks like this, built in Qt6, with my most commonly used settings:
![image](https://github.com/user-attachments/assets/36ad2131-6677-4559-bd6f-314a90c27218)
Simply drag and drop your files/folders into the KCC window,
adjust your settings (hover over each option to see details in a tooltip),
and hit convert to create ereader optimized files.
You can change the default output directory by holding `Shift` while clicking the convert button.
Then just drag and drop the generated output files onto your device's documents folder via USB.
If you are on macOS and use a 2022+ Kindle, you may need to use Amazon USB File Manager for Mac.
If you are on macOS and use a 2022+ Kindle, you may need to use Amazon USB File Manager for Mac or OpenMTP.
YouTube tutorial (please subscribe): https://www.youtube.com/watch?v=QQ6zJcMF2Iw
Installation tutorial: https://www.youtube.com/watch?v=IR2Fhcm9658
## Kindle Jailbreak for KOreader
Jailbreaking to use KOreader is optional. KCC works just fine with the native mobi manga viewer.
But if you jailbreak your Kindle, you'll unlock additional features like:
1) compatibility with image formats better suited for manga like 4-bit PNG and WEBP. This enables better quality at **half the file size** compared to JPG which must be 8-bit.
This is visually lossless since eink screens are 4-bit.
2) no dependency on kindlegen, which can mean **twice as fast conversions** since you can convert to CBZ directly.
3) You can dither by partially checking the JPG/PNG box and can crop in KCC instead of KOreader. This may increase page turn speed and battery.
### A word of warning
**KCC** _is not_ [Amazon's Kindle Comic Creator](http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1001103761) nor is in any way endorsed by Amazon.
Amazon's tool is for comic publishers and involves a lot of manual effort, while **KCC** is for comic/manga readers.
@@ -147,6 +175,8 @@ You'll need to install various tools to access important but optional features.
### KindleGen
(This is not needed for Koreader users on jailbroken Kindle. Just set output to CBZ instead.)
On Windows and macOS, install [Kindle Previewer](https://www.amazon.com/Kindle-Previewer/b?ie=UTF8&node=21381691011) and `kindlegen` will be autodetected from it.
If you have issues detecting it, get stuck on the MOBI conversion step, or use Linux AppImage or Flatpak, refer to the wiki: https://github.com/ciromattia/kcc/wiki/Installation#kindlegen
@@ -257,6 +287,7 @@ PROCESSING:
--pdfwidth Render vector PDFs based on device width instead of height.
-u, --upscale Resize images smaller than device's resolution
-s, --stretch Stretch images to device's resolution
--wallpaper Crop images to to fill screen
-r SPLITTER, --splitter SPLITTER
Double page parsing mode. 0: Split 1: Rotate 2: Both [Default=0]
-g GAMMA, --gamma GAMMA
+89 -61
View File
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>644</width>
<width>649</width>
<height>706</height>
</rect>
</property>
@@ -693,6 +693,18 @@ Keeping this file may crash some readers like the Kobo native CBZ reader.</strin
</property>
</widget>
</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>
</widget>
</item>
@@ -711,7 +723,27 @@ Keeping this file may crash some readers like the Kobo native CBZ reader.</strin
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="2">
<item row="0" column="0">
<widget class="QPushButton" name="editorButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p style='white-space:pre'&gt;Shift+Click to edit directory.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Metadata Editor</string>
</property>
<property name="icon">
<iconset resource="KCC.qrc">
<normaloff>:/Other/icons/editor.png</normaloff>:/Other/icons/editor.png</iconset>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="humbleButton">
<property name="minimumSize">
<size>
@@ -728,7 +760,7 @@ Keeping this file may crash some readers like the Kobo native CBZ reader.</strin
</property>
</widget>
</item>
<item row="0" column="1">
<item row="0" column="2">
<widget class="QPushButton" name="kofiButton">
<property name="minimumSize">
<size>
@@ -751,8 +783,8 @@ Keeping this file may crash some readers like the Kobo native CBZ reader.</strin
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="editorButton">
<item row="0" column="1">
<widget class="QPushButton" name="labelSpreadsButton">
<property name="minimumSize">
<size>
<width>0</width>
@@ -760,14 +792,10 @@ Keeping this file may crash some readers like the Kobo native CBZ reader.</strin
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p style='white-space:pre'&gt;Shift+Click to edit directory.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>Hold shift while clicking for a low quality preview.</string>
</property>
<property name="text">
<string>Metadata Editor</string>
</property>
<property name="icon">
<iconset resource="KCC.qrc">
<normaloff>:/Other/icons/editor.png</normaloff>:/Other/icons/editor.png</iconset>
<string>Label Spreads</string>
</property>
</widget>
</item>
@@ -1074,6 +1102,56 @@ Keeping this file may crash some readers like the Kobo native CBZ reader.</strin
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="1">
<widget class="QComboBox" name="deviceBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p style='white-space:pre'&gt;Target device.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="clearButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Clear list</string>
</property>
<property name="icon">
<iconset resource="KCC.qrc">
<normaloff>:/Other/icons/clear.png</normaloff>:/Other/icons/clear.png</iconset>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="directoryButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p style='white-space:pre'&gt;Add directory containing JPG, PNG or GIF files to queue.&lt;br/&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;CBR, CBZ and CB7 files inside will not be processed!&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Add input folder(s)</string>
</property>
<property name="icon">
<iconset resource="KCC.qrc">
<normaloff>:/Other/icons/folder_new.png</normaloff>:/Other/icons/folder_new.png</iconset>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="convertButton">
<property name="minimumSize">
@@ -1099,36 +1177,6 @@ Keeping this file may crash some readers like the Kobo native CBZ reader.</strin
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="clearButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Clear list</string>
</property>
<property name="icon">
<iconset resource="KCC.qrc">
<normaloff>:/Other/icons/clear.png</normaloff>:/Other/icons/clear.png</iconset>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="deviceBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p style='white-space:pre'&gt;Target device.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="fileButton">
<property name="minimumSize">
@@ -1149,26 +1197,6 @@ Keeping this file may crash some readers like the Kobo native CBZ reader.</strin
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="directoryButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p style='white-space:pre'&gt;Add directory containing JPG, PNG or GIF files to queue.&lt;br/&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;CBR, CBZ and CB7 files inside will not be processed!&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Add input folder(s)</string>
</property>
<property name="icon">
<iconset resource="KCC.qrc">
<normaloff>:/Other/icons/folder_new.png</normaloff>:/Other/icons/folder_new.png</iconset>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QComboBox" name="formatBox">
<property name="minimumSize">
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 351 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 367 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 438 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

View File

Before

Width:  |  Height:  |  Size: 921 KiB

After

Width:  |  Height:  |  Size: 921 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 513 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB

+247 -132
View File
@@ -19,10 +19,11 @@
from datetime import datetime, timezone
import itertools
import json
from pathlib import Path
from PySide6.QtCore import (QSize, QUrl, Qt, Signal, QIODeviceBase, QEvent, QThread, QSettings)
from PySide6.QtGui import (QColor, QIcon, QPixmap, QDesktopServices)
from PySide6.QtWidgets import (QApplication, QLabel, QListWidgetItem, QMainWindow, QSystemTrayIcon, QFileDialog, QMessageBox, QDialog, QAbstractItemView, QListView, QTreeView)
from PySide6.QtGui import (QColor, QIcon, QImage, QKeyEvent, QPixmap, QDesktopServices)
from PySide6.QtWidgets import (QApplication, QDialogButtonBox, QHBoxLayout, QLabel, QListWidgetItem, QMainWindow, QSizePolicy, QSystemTrayIcon, QFileDialog, QMessageBox, QDialog, QAbstractItemView, QListView, QTreeView, QWidget)
from PySide6.QtNetwork import (QLocalSocket, QLocalServer)
import os
@@ -38,10 +39,15 @@ from xml.sax.saxutils import escape
from psutil import Process
from copy import copy
from packaging.version import Version
from tempfile import gettempdir
from tempfile import gettempdir, mkdtemp
from PIL import Image
from PIL.Image import Dither
from .KCC_spread_label import LabelSpreadsDialog
from .shared import HTMLStripper, sanitizeTrace, walkLevel, subprocess_run
from .comicarchive import SEVENZIP, TAR, available_archive_tools
from .comic2ebook import OS_SORT_KEY, flattenTree, getWorkFolder, removeNonImages, sanitizeTree
from . import __version__
from . import comic2ebook
from . import metadata
@@ -121,6 +127,8 @@ class Icons:
self.MOBIFormat.addPixmap(QPixmap(":/Formats/icons/MOBI.png"), QIcon.Mode.Normal, QIcon.State.Off)
self.CBZFormat = QIcon()
self.CBZFormat.addPixmap(QPixmap(":/Formats/icons/CBZ.png"), QIcon.Mode.Normal, QIcon.State.Off)
self.FOLDERFormat = QIcon()
self.FOLDERFormat.addPixmap(QPixmap(":/Other/icons/folder_new.png"), QIcon.Mode.Normal, QIcon.State.Off)
self.EPUBFormat = QIcon()
self.EPUBFormat.addPixmap(QPixmap(":/Formats/icons/EPUB.png"), QIcon.Mode.Normal, QIcon.State.Off)
self.KFXFormat = QIcon()
@@ -234,6 +242,140 @@ class ProgressThread(QThread):
self.running = False
def get_options():
parser = comic2ebook.makeParser()
options = parser.parse_args()
options.profile = GUI.profiles[str(GUI.deviceBox.currentText())]['Label']
gui_current_format = GUI.formats[str(GUI.formatBox.currentText())]['format']
options.format = gui_current_format
if GUI.mangaBox.isChecked():
options.righttoleft = True
if GUI.lightnovelBox.isChecked():
options.lightnovel = True
if GUI.wallpaperBox.isChecked():
options.wallpaper = True
if GUI.ebokBox.isChecked():
options.ebok = True
if GUI.invertDirectionBox.isChecked():
options.invertdirection = True
if GUI.rotateBox.checkState() == Qt.CheckState.PartiallyChecked:
options.splitter = 2
elif GUI.rotateBox.checkState() == Qt.CheckState.Checked:
options.splitter = 1
if GUI.qualityBox.checkState() == Qt.CheckState.PartiallyChecked:
options.autoscale = True
elif GUI.qualityBox.checkState() == Qt.CheckState.Checked:
options.hq = True
if GUI.vertical4PanelBox.isChecked():
options.vertical4panel = True
if GUI.webtoonBox.isChecked():
options.webtoon = True
if GUI.upscaleBox.checkState() == Qt.CheckState.PartiallyChecked:
options.stretch = True
elif GUI.upscaleBox.checkState() == Qt.CheckState.Checked:
options.upscale = True
if GUI.gammaBox.isChecked() and float(GUI.gammaValue) > 0.09:
options.gamma = float(GUI.gammaValue)
if GUI.autoLevelBox.isChecked():
options.autolevel = True
if GUI.autocontrastBox.checkState() == Qt.CheckState.PartiallyChecked:
options.noautocontrast = True
elif GUI.autocontrastBox.checkState() == Qt.CheckState.Checked:
options.colorautocontrast = True
if GUI.croppingBox.isChecked():
if GUI.croppingBox.checkState() == Qt.CheckState.PartiallyChecked:
options.cropping = 1
else:
options.cropping = 2
else:
options.cropping = 0
if GUI.croppingBox.checkState() != Qt.CheckState.Unchecked:
options.croppingp = float(GUI.croppingPowerValue)
options.preservemargin = GUI.preserveMarginBox.value()
if GUI.interPanelCropBox.isChecked():
if GUI.interPanelCropBox.checkState() == Qt.CheckState.PartiallyChecked:
options.interpanelcrop = 1
else:
options.interpanelcrop = 2
else:
options.interpanelcrop = 0
if GUI.borderBox.checkState() == Qt.CheckState.PartiallyChecked:
options.white_borders = True
elif GUI.borderBox.checkState() == Qt.CheckState.Checked:
options.black_borders = True
if GUI.outputSplit.isChecked():
options.batchsplit = 2
if GUI.colorBox.isChecked():
options.forcecolor = True
if GUI.eraseRainbowBox.isChecked():
options.eraserainbow = True
if GUI.maximizeStrips.isChecked():
options.maximizestrips = True
if GUI.disableProcessingBox.isChecked():
options.noprocessing = True
if GUI.legacyExtractBox.isChecked():
options.legacyextract = 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:
options.metadatatitle = 1
elif GUI.metadataTitleBox.checkState() == Qt.CheckState.Checked:
options.metadatatitle = 2
if GUI.keepComicInfoBox.isChecked():
options.keepcomicinfo = True
if GUI.deleteBox.isChecked():
options.delete = True
if GUI.tempDirBox.isChecked():
options.tempdir = True
if GUI.spreadShiftBox.isChecked():
options.spreadshift = True
if GUI.onePageLandscapeBox.isChecked():
options.onepagelandscape = True
if GUI.fileFusionBox.isChecked():
options.filefusion = True
else:
options.filefusion = False
if GUI.noRotateBox.isChecked():
options.norotate = True
if GUI.rotateRightBox.isChecked():
options.rotateright = True
if GUI.rotateFirstBox.isChecked():
options.rotatefirst = True
if GUI.forcePngRgbBox.isChecked():
options.force_png_rgb = True
if GUI.mozJpegBox.checkState() == Qt.CheckState.PartiallyChecked:
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():
options.noquantize = True
if GUI.jpegQualityBox.isChecked():
options.jpegquality = GUI.jpegQualitySpinBox.value()
if GUI.currentMode > 2:
options.customwidth = str(GUI.widthBox.value())
options.customheight = str(GUI.heightBox.value())
if GUI.targetDirectory != '':
options.output = GUI.targetDirectory
if GUI.titleEdit.text():
options.title = str(GUI.titleEdit.text())
if GUI.authorEdit.text():
options.author = str(GUI.authorEdit.text())
if GUI.languageEdit.text():
options.language = str(GUI.languageEdit.text())
if GUI.chunkSizeCheckBox.isChecked():
options.targetsize = int(GUI.chunkSizeBox.value())
return options, gui_current_format
class WorkerThread(QThread):
def __init__(self):
QThread.__init__(self)
@@ -263,136 +405,9 @@ class WorkerThread(QThread):
def run(self):
MW.modeConvert.emit(0)
parser = comic2ebook.makeParser()
options = parser.parse_args()
argv = ''
currentJobs = []
options.profile = GUI.profiles[str(GUI.deviceBox.currentText())]['Label']
gui_current_format = GUI.formats[str(GUI.formatBox.currentText())]['format']
options.format = gui_current_format
if GUI.mangaBox.isChecked():
options.righttoleft = True
if GUI.lightnovelBox.isChecked():
options.lightnovel = True
if GUI.ebokBox.isChecked():
options.ebok = True
if GUI.invertDirectionBox.isChecked():
options.invertdirection = True
if GUI.rotateBox.checkState() == Qt.CheckState.PartiallyChecked:
options.splitter = 2
elif GUI.rotateBox.checkState() == Qt.CheckState.Checked:
options.splitter = 1
if GUI.qualityBox.checkState() == Qt.CheckState.PartiallyChecked:
options.autoscale = True
elif GUI.qualityBox.checkState() == Qt.CheckState.Checked:
options.hq = True
if GUI.vertical4PanelBox.isChecked():
options.vertical4panel = True
if GUI.webtoonBox.isChecked():
options.webtoon = True
if GUI.upscaleBox.checkState() == Qt.CheckState.PartiallyChecked:
options.stretch = True
elif GUI.upscaleBox.checkState() == Qt.CheckState.Checked:
options.upscale = True
if GUI.gammaBox.isChecked() and float(GUI.gammaValue) > 0.09:
options.gamma = float(GUI.gammaValue)
if GUI.autoLevelBox.isChecked():
options.autolevel = True
if GUI.autocontrastBox.checkState() == Qt.CheckState.PartiallyChecked:
options.noautocontrast = True
elif GUI.autocontrastBox.checkState() == Qt.CheckState.Checked:
options.colorautocontrast = True
if GUI.croppingBox.isChecked():
if GUI.croppingBox.checkState() == Qt.CheckState.PartiallyChecked:
options.cropping = 1
else:
options.cropping = 2
else:
options.cropping = 0
if GUI.croppingBox.checkState() != Qt.CheckState.Unchecked:
options.croppingp = float(GUI.croppingPowerValue)
options.preservemargin = GUI.preserveMarginBox.value()
if GUI.interPanelCropBox.isChecked():
if GUI.interPanelCropBox.checkState() == Qt.CheckState.PartiallyChecked:
options.interpanelcrop = 1
else:
options.interpanelcrop = 2
else:
options.interpanelcrop = 0
if GUI.borderBox.checkState() == Qt.CheckState.PartiallyChecked:
options.white_borders = True
elif GUI.borderBox.checkState() == Qt.CheckState.Checked:
options.black_borders = True
if GUI.outputSplit.isChecked():
options.batchsplit = 2
if GUI.colorBox.isChecked():
options.forcecolor = True
if GUI.eraseRainbowBox.isChecked():
options.eraserainbow = True
if GUI.maximizeStrips.isChecked():
options.maximizestrips = True
if GUI.disableProcessingBox.isChecked():
options.noprocessing = True
if GUI.legacyExtractBox.isChecked():
options.legacyextract = 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:
options.metadatatitle = 1
elif GUI.metadataTitleBox.checkState() == Qt.CheckState.Checked:
options.metadatatitle = 2
if GUI.keepComicInfoBox.isChecked():
options.keepcomicinfo = True
if GUI.deleteBox.isChecked():
options.delete = True
if GUI.tempDirBox.isChecked():
options.tempdir = True
if GUI.spreadShiftBox.isChecked():
options.spreadshift = True
if GUI.onePageLandscapeBox.isChecked():
options.onepagelandscape = True
if GUI.fileFusionBox.isChecked():
options.filefusion = True
else:
options.filefusion = False
if GUI.noRotateBox.isChecked():
options.norotate = True
if GUI.rotateRightBox.isChecked():
options.rotateright = True
if GUI.rotateFirstBox.isChecked():
options.rotatefirst = True
if GUI.forcePngRgbBox.isChecked():
options.force_png_rgb = True
if GUI.mozJpegBox.checkState() == Qt.CheckState.PartiallyChecked:
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():
options.noquantize = True
if GUI.jpegQualityBox.isChecked():
options.jpegquality = GUI.jpegQualitySpinBox.value()
if GUI.currentMode > 2:
options.customwidth = str(GUI.widthBox.value())
options.customheight = str(GUI.heightBox.value())
if GUI.targetDirectory != '':
options.output = GUI.targetDirectory
if GUI.titleEdit.text():
options.title = str(GUI.titleEdit.text())
if GUI.authorEdit.text():
options.author = str(GUI.authorEdit.text())
if GUI.languageEdit.text():
options.language = str(GUI.languageEdit.text())
if GUI.chunkSizeCheckBox.isChecked():
options.targetsize = int(GUI.chunkSizeBox.value())
options, gui_current_format = get_options()
for i in range(GUI.jobList.count()):
# Make sure that we don't consider any system message as job to do
@@ -431,6 +446,9 @@ class WorkerThread(QThread):
if gui_current_format == 'CBZ':
MW.addMessage.emit('Creating CBZ files', 'info', False)
GUI.progress.content = 'Creating CBZ files'
elif gui_current_format == 'FOLDER':
MW.addMessage.emit('Creating folders', 'info', False)
GUI.progress.content = 'Creating folders'
elif gui_current_format == 'PDF':
MW.addMessage.emit('Creating PDF files', 'info', False)
GUI.progress.content = 'Creating PDF files'
@@ -476,6 +494,8 @@ class WorkerThread(QThread):
GUI.progress.content = ''
if gui_current_format == 'CBZ':
MW.addMessage.emit('Creating CBZ files... <b>Done!</b>', 'info', True)
elif gui_current_format == 'FOLDER':
MW.addMessage.emit('Creating folders... <b>Done!</b>', 'info', True)
elif gui_current_format == 'PDF':
MW.addMessage.emit('Creating PDF files... <b>Done!</b>', 'info', True)
else:
@@ -659,6 +679,87 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
GUI.jobList.addItem(dname)
GUI.jobList.scrollToBottom()
def labelSpreadsStart(self):
low_quality_preview = False
if QApplication.keyboardModifiers() == Qt.ShiftModifier:
low_quality_preview = True
currentJobs = []
# TODO: make this a function since it's copy pasted
for i in range(GUI.jobList.count()):
# Make sure that we don't consider any system message as job to do
if GUI.jobList.item(i).icon().isNull():
currentJobs.append(str(GUI.jobList.item(i).text()))
for job in currentJobs:
images = []
spreads = []
options, _ = get_options()
options.profileData = [(600, 800), (600,800)]
path = getWorkFolder(job, options)
removeNonImages(path)
sanitizeTree(path, options)
flattenTree(path)
if options.tempdir:
workdir = mkdtemp('', 'KCC-', os.path.dirname(job))
else:
workdir = mkdtemp('', 'KCC-')
for root, _, files in os.walk(path):
files.sort(key=OS_SORT_KEY)
start_index = 0
if job.endswith('.pdf') or job.endswith('.epub'):
start_index = 1
if options.spreadshift:
start_index = 0 if start_index == 1 else 1
for i in range(start_index, len(files), 2):
if i == len(files) - 1:
continue
# TODO: with statements
# TODO: ignore 1% of top and bottom too?
im1 = Image.open(os.path.join(root, files[i]))
im2 = Image.open(os.path.join(root, files[i+1]))
if not options.righttoleft:
im1, im2 = im2, im1
size1 = im1.size
size2 = im2.size
preview_crop1 = im1.crop((0, 0, 0.2*size1[0], size1[1]))
if low_quality_preview:
preview_crop1 = preview_crop1.convert('1', dither=Dither.NONE)
calculation_crop1 = im1.crop((0.01*size1[0], 0, 0.04*size1[0], size1[1])).convert('1', dither=Dither.NONE)
preview_crop2 = im2.crop((0.8*size2[0], 0, size2[0], size2[1]))
if low_quality_preview:
preview_crop2 = preview_crop2.convert('1', dither=Dither.NONE)
calculation_crop2 = im2.crop((0.96*size2[0], 0, .99* size2[0], size2[1])).convert('1', dither=Dither.NONE)
# dst = Image.new('1', (im1.width + im2.width, im1.height))
# dst.paste(im2, (0, 0))
# dst.paste(im1, (im1.width, 0))
hist1 = calculation_crop1.histogram()
hist2 = calculation_crop2.histogram()
# TODO: small percentage instead of zero
if hist1[0] == 0 or hist1[-1] == 0 or hist2[0] == 0 or hist2[-1] == 0:
continue
preview_mode = '1' if low_quality_preview else 'RGB'
dst = Image.new(preview_mode, (preview_crop1.width + preview_crop2.width, preview_crop1.height))
dst.paste(preview_crop2, (0, 0))
dst.paste(preview_crop1, (preview_crop1.width, 0))
dst.save(os.path.join(workdir, f'label-{i:04}.png'))
images.append(os.path.join(workdir, f'label-{i:04}.png'))
if images:
dlg = LabelSpreadsDialog(APP.primaryScreen().availableGeometry().height(), images, spreads)
dlg.setWindowTitle(job)
if dlg.exec() == 1:
with open(job+'.json', "w") as fp:
# TODO: not very clean to grab index from filename
spreads = [int(filename[6:10]) for filename in spreads]
json.dump({'spreads': sorted(set(spreads))} , fp)
rmtree(path, True)
rmtree(workdir, True)
def selectFileMetaEditor(self, sname):
files = []
@@ -870,6 +971,14 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
GUI.noQuantizeBox.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):
GUI.chunkSizeWidget.setVisible(value)
@@ -969,9 +1078,10 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
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():
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')
GUI.borderBox.setCheckState(Qt.CheckState.PartiallyChecked)
GUI.mozJpegBox.setCheckState(Qt.CheckState.PartiallyChecked)
else:
GUI.borderBox.setCheckState(Qt.CheckState.Unchecked)
@@ -1086,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('options', {'mangaBox': GUI.mangaBox.checkState(),
'lightnovelBox': GUI.lightnovelBox.checkState(),
'wallpaperBox': GUI.wallpaperBox.checkState(),
'ebokBox': GUI.ebokBox.checkState(),
'invertDirectionBox': GUI.invertDirectionBox.checkState(),
'languageEdit': GUI.languageEdit.text(),
@@ -1267,6 +1378,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
"MOBI/AZW3": {'icon': 'MOBI', 'format': 'MOBI'},
"EPUB": {'icon': 'EPUB', 'format': 'EPUB'},
"CBZ": {'icon': 'CBZ', 'format': 'CBZ'},
"Folder of images": {'icon': 'FOLDER', 'format': 'FOLDER'},
"PDF": {'icon': 'EPUB', 'format': 'PDF'},
"PDF (200MB limit)": {'icon': 'EPUB', 'format': 'PDF-200MB'},
"KFX (Send to Kindle EPUB)": {'icon': 'KFX', 'format': 'KFX'},
@@ -1436,6 +1548,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
'README': "https://github.com/ciromattia/kcc?tab=readme-ov-file#kcc",
'FAQ': "https://github.com/ciromattia/kcc/blob/master/README.md#faq",
'WIKI': "https://github.com/ciromattia/kcc/wiki",
'YOUTUBE': "https://www.youtube.com/@eink-dude",
'TUTORIAL': "https://youtu.be/QQ6zJcMF2Iw?si=80rfm6DU6OUJdFqa",
'EMAIL': "https://github.com/ciromattia/kcc?tab=readme-ov-file#commissions",
'DONATE': "https://github.com/ciromattia/kcc/blob/master/README.md#issues--new-features--donations",
@@ -1472,6 +1585,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
GUI.kofiButton.clicked.connect(self.openKofi)
GUI.humbleButton.clicked.connect(self.openHumble)
GUI.convertButton.clicked.connect(self.convertStart)
GUI.labelSpreadsButton.clicked.connect(self.labelSpreadsStart)
GUI.gammaSlider.valueChanged.connect(self.changeGamma)
GUI.gammaBox.stateChanged.connect(self.togglegammaBox)
GUI.croppingBox.stateChanged.connect(self.togglecroppingBox)
@@ -1480,6 +1594,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
GUI.webtoonBox.stateChanged.connect(self.togglewebtoonBox)
GUI.qualityBox.stateChanged.connect(self.togglequalityBox)
GUI.mozJpegBox.stateChanged.connect(self.toggleImageFormatBox)
GUI.wallpaperBox.stateChanged.connect(self.toggleWallpaperBox)
GUI.chunkSizeCheckBox.stateChanged.connect(self.togglechunkSizeCheckBox)
GUI.deviceBox.activated.connect(self.changeDevice)
GUI.formatBox.activated.connect(self.changeFormat)
+92
View File
@@ -0,0 +1,92 @@
import os
from PySide6.QtCore import (Qt)
from PySide6.QtGui import (QKeyEvent, QPixmap)
from PySide6.QtWidgets import (QHBoxLayout, QLabel, QDialog)
class LabelSpreadsDialog(QDialog):
def __init__(self, available_height, images, spreads):
super().__init__()
self.index = 0
self.images = images
self.spreads = spreads
self.index2page = {i: os.path.basename(image) for i, image in enumerate(images)}
self.setWindowTitle("TODO: Filename goes here")
# self.setGeometry(APP.primaryScreen().availableGeometry())
# self.setMaximumSize(APP.primaryScreen().availableSize())
self.available_height = available_height
layout = QHBoxLayout()
self.setLayout(layout)
label = QLabel()
label2 = QLabel()
self.label = label
self.label2 = label2
layout.addWidget(label)
layout.addWidget(label2)
label2.setText("not a spread")
help_text = [
"Use arrows to change index.",
"Use space bar to confirm spreads.",
"Use spread shift option to offset by 1.",
"Use enter key to confirm all spreads."
"Close window to cancel."
]
buttonLabel = QLabel('\n'.join(help_text))
layout.addWidget(buttonLabel)
# print(label.size())
# print(label.maximumSize())
# l, t, r, b = layout.getContentsMargins()
#label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
pixmap = QPixmap(images[0]).scaledToHeight(self.available_height * 0.9)
label.setPixmap(pixmap)
#label.setScaledContents(True)
#label2.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
# pixmap2 = QPixmap(images[0]).scaledToHeight(self.frameGeometry().height() - t - b - t - b)
# label2.setPixmap(pixmap2)
#label2.setScaledContents(True)
#self.resize(pixmap2.width(), pixmap2.height())
def keyReleaseEvent(self, event):
# t = 20
# b = 20
if isinstance(event, QKeyEvent):
if event.key() == Qt.Key.Key_Left:
self.index = max(0, self.index - 1)
if self.index2page[self.index] in self.spreads:
self.label2.setText('spread')
else:
self.label2.setText('not a spread')
pixmap = QPixmap(self.images[self.index]).scaledToHeight(self.available_height * 0.9)
self.label.setPixmap(pixmap)
# pixmap2 = QPixmap(images[self.index]).scaledToHeight(self.frameGeometry().height() - t - b - t - b)
# self.label2.setPixmap(pixmap2)
elif event.key() == Qt.Key.Key_Right:
self.index = min(self.index + 1, len(self.images) - 1)
if self.index2page[self.index] in self.spreads:
self.label2.setText('spread')
else:
self.label2.setText('not a spread')
pixmap = QPixmap(self.images[self.index]).scaledToHeight(self.available_height * 0.9)
self.label.setPixmap(pixmap)
# pixmap2 = QPixmap(images[self.index]).scaledToHeight(self.frameGeometry().height() - t - b - t - b)
# self.label2.setPixmap(pixmap2)
elif event.key() == Qt.Key.Key_Space:
if self.label2.text() == "not a spread":
self.spreads.append(os.path.basename(self.images[self.index]))
self.label2.setText('spread')
else:
self.spreads.remove(os.path.basename(self.images[self.index]))
self.label2.setText('not a spread')
elif event.key() == Qt.Key.Key_Return or event.key() == Qt.Key.Key_Enter:
self.accept()
else:
super().keyReleaseEvent(event)
else:
super().keyReleaseEvent(event)
+74 -53
View File
@@ -26,7 +26,7 @@ class Ui_mainWindow(object):
def setupUi(self, mainWindow):
if not mainWindow.objectName():
mainWindow.setObjectName(u"mainWindow")
mainWindow.resize(644, 706)
mainWindow.resize(649, 706)
icon = QIcon()
icon.addFile(u":/Icon/icons/comic2ebook.png", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
mainWindow.setWindowIcon(icon)
@@ -352,6 +352,11 @@ class Ui_mainWindow(object):
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)
@@ -360,33 +365,39 @@ class Ui_mainWindow(object):
self.gridLayout_6 = QGridLayout(self.toolWidget)
self.gridLayout_6.setObjectName(u"gridLayout_6")
self.gridLayout_6.setContentsMargins(0, 0, 0, 0)
self.editorButton = QPushButton(self.toolWidget)
self.editorButton.setObjectName(u"editorButton")
self.editorButton.setMinimumSize(QSize(0, 30))
icon2 = QIcon()
icon2.addFile(u":/Other/icons/editor.png", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
self.editorButton.setIcon(icon2)
self.gridLayout_6.addWidget(self.editorButton, 0, 0, 1, 1)
self.humbleButton = QPushButton(self.toolWidget)
self.humbleButton.setObjectName(u"humbleButton")
self.humbleButton.setMinimumSize(QSize(0, 30))
icon2 = QIcon()
icon2.addFile(u":/Brand/icons/Humble_H-Red.png", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
self.humbleButton.setIcon(icon2)
icon3 = QIcon()
icon3.addFile(u":/Brand/icons/Humble_H-Red.png", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
self.humbleButton.setIcon(icon3)
self.gridLayout_6.addWidget(self.humbleButton, 0, 2, 1, 1)
self.gridLayout_6.addWidget(self.humbleButton, 0, 3, 1, 1)
self.kofiButton = QPushButton(self.toolWidget)
self.kofiButton.setObjectName(u"kofiButton")
self.kofiButton.setMinimumSize(QSize(0, 30))
icon3 = QIcon()
icon3.addFile(u":/Brand/icons/kofi_symbol.png", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
self.kofiButton.setIcon(icon3)
icon4 = QIcon()
icon4.addFile(u":/Brand/icons/kofi_symbol.png", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
self.kofiButton.setIcon(icon4)
self.kofiButton.setIconSize(QSize(19, 16))
self.gridLayout_6.addWidget(self.kofiButton, 0, 1, 1, 1)
self.gridLayout_6.addWidget(self.kofiButton, 0, 2, 1, 1)
self.editorButton = QPushButton(self.toolWidget)
self.editorButton.setObjectName(u"editorButton")
self.editorButton.setMinimumSize(QSize(0, 30))
icon4 = QIcon()
icon4.addFile(u":/Other/icons/editor.png", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
self.editorButton.setIcon(icon4)
self.labelSpreadsButton = QPushButton(self.toolWidget)
self.labelSpreadsButton.setObjectName(u"labelSpreadsButton")
self.labelSpreadsButton.setMinimumSize(QSize(0, 30))
self.gridLayout_6.addWidget(self.editorButton, 0, 0, 1, 1)
self.gridLayout_6.addWidget(self.labelSpreadsButton, 0, 1, 1, 1)
self.gridLayout.addWidget(self.toolWidget, 0, 0, 1, 2)
@@ -543,39 +554,20 @@ class Ui_mainWindow(object):
self.gridLayout_4 = QGridLayout(self.buttonWidget)
self.gridLayout_4.setObjectName(u"gridLayout_4")
self.gridLayout_4.setContentsMargins(0, 0, 0, 0)
self.convertButton = QPushButton(self.buttonWidget)
self.convertButton.setObjectName(u"convertButton")
self.convertButton.setMinimumSize(QSize(0, 30))
self.convertButton.setFont(font)
icon5 = QIcon()
icon5.addFile(u":/Other/icons/convert.png", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
self.convertButton.setIcon(icon5)
self.gridLayout_4.addWidget(self.convertButton, 1, 3, 1, 1)
self.clearButton = QPushButton(self.buttonWidget)
self.clearButton.setObjectName(u"clearButton")
self.clearButton.setMinimumSize(QSize(0, 30))
icon6 = QIcon()
icon6.addFile(u":/Other/icons/clear.png", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
self.clearButton.setIcon(icon6)
self.gridLayout_4.addWidget(self.clearButton, 0, 3, 1, 1)
self.deviceBox = QComboBox(self.buttonWidget)
self.deviceBox.setObjectName(u"deviceBox")
self.deviceBox.setMinimumSize(QSize(0, 28))
self.gridLayout_4.addWidget(self.deviceBox, 1, 1, 1, 1)
self.fileButton = QPushButton(self.buttonWidget)
self.fileButton.setObjectName(u"fileButton")
self.fileButton.setMinimumSize(QSize(0, 30))
icon7 = QIcon()
icon7.addFile(u":/Other/icons/document_new.png", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
self.fileButton.setIcon(icon7)
self.clearButton = QPushButton(self.buttonWidget)
self.clearButton.setObjectName(u"clearButton")
self.clearButton.setMinimumSize(QSize(0, 30))
icon5 = QIcon()
icon5.addFile(u":/Other/icons/clear.png", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
self.clearButton.setIcon(icon5)
self.gridLayout_4.addWidget(self.fileButton, 0, 1, 1, 1)
self.gridLayout_4.addWidget(self.clearButton, 0, 3, 1, 1)
self.directoryButton = QPushButton(self.buttonWidget)
self.directoryButton.setObjectName(u"directoryButton")
@@ -588,6 +580,25 @@ class Ui_mainWindow(object):
self.gridLayout_4.addWidget(self.directoryButton, 0, 4, 1, 1)
self.convertButton = QPushButton(self.buttonWidget)
self.convertButton.setObjectName(u"convertButton")
self.convertButton.setMinimumSize(QSize(0, 30))
self.convertButton.setFont(font)
icon6 = QIcon()
icon6.addFile(u":/Other/icons/convert.png", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
self.convertButton.setIcon(icon6)
self.gridLayout_4.addWidget(self.convertButton, 1, 3, 1, 1)
self.fileButton = QPushButton(self.buttonWidget)
self.fileButton.setObjectName(u"fileButton")
self.fileButton.setMinimumSize(QSize(0, 30))
icon7 = QIcon()
icon7.addFile(u":/Other/icons/document_new.png", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
self.fileButton.setIcon(icon7)
self.gridLayout_4.addWidget(self.fileButton, 0, 1, 1, 1)
self.formatBox = QComboBox(self.buttonWidget)
self.formatBox.setObjectName(u"formatBox")
self.formatBox.setMinimumSize(QSize(0, 28))
@@ -848,12 +859,22 @@ class Ui_mainWindow(object):
"Keeping this file may crash some readers like the Kobo native CBZ reader.", None))
#endif // QT_CONFIG(tooltip)
self.keepComicInfoBox.setText(QCoreApplication.translate("mainWindow", u"Keep ComicInfo.xml", None))
self.humbleButton.setText(QCoreApplication.translate("mainWindow", u"Humble Bundle Referral", None))
self.kofiButton.setText(QCoreApplication.translate("mainWindow", u"Support me on Ko-fi", 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)
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)
self.editorButton.setText(QCoreApplication.translate("mainWindow", u"Metadata Editor", None))
self.humbleButton.setText(QCoreApplication.translate("mainWindow", u"Humble Bundle Referral", None))
self.kofiButton.setText(QCoreApplication.translate("mainWindow", u"Support me on Ko-fi", None))
#if QT_CONFIG(tooltip)
self.labelSpreadsButton.setToolTip(QCoreApplication.translate("mainWindow", u"Hold shift while clicking for a low quality preview.", None))
#endif // QT_CONFIG(tooltip)
self.labelSpreadsButton.setText(QCoreApplication.translate("mainWindow", u"Label Spreads", None))
#if QT_CONFIG(tooltip)
self.chunkSizeWidget.setToolTip(QCoreApplication.translate("mainWindow", u"<html><head/><body><p>Warning: chunk size greater than default may cause<br/>performance/battery issues, especially on older devices.</p></body></html>", None))
#endif // QT_CONFIG(tooltip)
@@ -878,22 +899,22 @@ class Ui_mainWindow(object):
#if QT_CONFIG(tooltip)
self.heightBox.setToolTip(QCoreApplication.translate("mainWindow", u"<html><head/><body><p style='white-space:pre'>Resolution of the target device.</p></body></html>", None))
#endif // QT_CONFIG(tooltip)
#if QT_CONFIG(tooltip)
self.convertButton.setToolTip(QCoreApplication.translate("mainWindow", u"<html><head/><body><p style='white-space:pre'>Shift+Click to select the output directory for this list.</p></body></html>", None))
#endif // QT_CONFIG(tooltip)
self.convertButton.setText(QCoreApplication.translate("mainWindow", u"Convert", None))
self.clearButton.setText(QCoreApplication.translate("mainWindow", u"Clear list", None))
#if QT_CONFIG(tooltip)
self.deviceBox.setToolTip(QCoreApplication.translate("mainWindow", u"<html><head/><body><p style='white-space:pre'>Target device.</p></body></html>", None))
#endif // QT_CONFIG(tooltip)
#if QT_CONFIG(tooltip)
self.fileButton.setToolTip(QCoreApplication.translate("mainWindow", u"<html><head/><body><p style='white-space:pre'>Add CBR, CBZ, CB7 or PDF file to queue.</p></body></html>", None))
#endif // QT_CONFIG(tooltip)
self.fileButton.setText(QCoreApplication.translate("mainWindow", u"Add input file(s)", None))
self.clearButton.setText(QCoreApplication.translate("mainWindow", u"Clear list", None))
#if QT_CONFIG(tooltip)
self.directoryButton.setToolTip(QCoreApplication.translate("mainWindow", u"<html><head/><body><p style='white-space:pre'>Add directory containing JPG, PNG or GIF files to queue.<br/><span style=\" font-weight:600;\">CBR, CBZ and CB7 files inside will not be processed!</span></p></body></html>", None))
#endif // QT_CONFIG(tooltip)
self.directoryButton.setText(QCoreApplication.translate("mainWindow", u"Add input folder(s)", None))
#if QT_CONFIG(tooltip)
self.convertButton.setToolTip(QCoreApplication.translate("mainWindow", u"<html><head/><body><p style='white-space:pre'>Shift+Click to select the output directory for this list.</p></body></html>", None))
#endif // QT_CONFIG(tooltip)
self.convertButton.setText(QCoreApplication.translate("mainWindow", u"Convert", None))
#if QT_CONFIG(tooltip)
self.fileButton.setToolTip(QCoreApplication.translate("mainWindow", u"<html><head/><body><p style='white-space:pre'>Add CBR, CBZ, CB7 or PDF file to queue.</p></body></html>", None))
#endif // QT_CONFIG(tooltip)
self.fileButton.setText(QCoreApplication.translate("mainWindow", u"Add input file(s)", None))
#if QT_CONFIG(tooltip)
self.formatBox.setToolTip(QCoreApplication.translate("mainWindow", u"<html><head/><body><p style='white-space:pre'>Output format.</p></body></html>", None))
#endif // QT_CONFIG(tooltip)
+1 -1
View File
@@ -1,4 +1,4 @@
__version__ = '10.4.0'
__version__ = '11.1.0'
__license__ = 'ISC'
__copyright__ = '2012-2022, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>, darodi'
__docformat__ = 'restructuredtext en'
+93 -19
View File
@@ -20,6 +20,7 @@
from collections import Counter
from datetime import datetime
import json
import os
import pathlib
import re
@@ -872,7 +873,7 @@ def extract_page(vector):
def mupdf_pdf_process_pages_parallel(filename, output_dir, target_width, target_height):
def mupdf_pdf_process_pages_parallel(filename, output_dir, target_width, target_height, pdfwidth):
render = False
with pymupdf.open(filename) as doc:
for page in doc:
@@ -891,8 +892,15 @@ def mupdf_pdf_process_pages_parallel(filename, output_dir, target_width, target_
cpu = cpu_count()
if not render:
print('PDF input can also use legacy extract option if you have any problems')
if GUI:
GUI.addMessage.emit('PDF input can also use legacy extract option if you have any problems'
, 'info', False)
GUI.addMessage.emit('', '', False)
# make vectors of arguments for the processes
vectors = [(i, cpu, filename, output_dir, target_width, target_height, options.pdfwidth) for i in range(cpu)]
vectors = [(i, cpu, filename, output_dir, target_width, target_height, pdfwidth) for i in range(cpu)]
print("Starting %i processes for '%s'." % (cpu, filename))
@@ -906,7 +914,7 @@ def mupdf_pdf_process_pages_parallel(filename, output_dir, target_width, target_
def getWorkFolder(afile, workdir=None):
def getWorkFolder(afile, options, workdir=None):
if not workdir:
if options.tempdir:
workdir = mkdtemp('', 'KCC-', os.path.dirname(afile))
@@ -955,7 +963,7 @@ def getWorkFolder(afile, workdir=None):
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)
mupdf_pdf_process_pages_parallel(afile, fullPath, target_width, target_height, options.pdfwidth)
except Exception as e:
rmtree(path, True)
raise UserWarning(f"Failed to extract images from PDF file. {e}")
@@ -979,9 +987,16 @@ def getWorkFolder(afile, workdir=None):
os.path.join(fullPath, tdir[0], 'ComicInfo.xml')
)
if len(tdir) == 1 and os.path.isdir(os.path.join(fullPath, tdir[0])):
if options.tempdir:
workdir2 = mkdtemp('', 'KCC-', os.path.dirname(afile))
else:
workdir2 = mkdtemp('', 'KCC-')
fullPath2 = os.path.join(workdir2, 'OEBPS', 'Images')
os.makedirs(fullPath2, exist_ok=True)
for file in os.listdir(os.path.join(fullPath, tdir[0])):
move(os.path.join(fullPath, tdir[0], file), fullPath)
os.rmdir(os.path.join(fullPath, tdir[0]))
move(os.path.join(fullPath, tdir[0], file), fullPath2)
rmtree(workdir, True)
return workdir2
if options.legacyextract:
return workdir
@@ -1050,6 +1065,8 @@ def getWorkFolder(afile, workdir=None):
def getOutputFilename(srcpath, wantedname, ext, tomenumber):
if options.folder_output:
ext = ''
source_path = Path(srcpath)
if srcpath[-1] == os.path.sep:
srcpath = srcpath[:-1]
@@ -1061,7 +1078,7 @@ def getOutputFilename(srcpath, wantedname, ext, tomenumber):
ext = '.kepub.epub'
if wantedname is not None:
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)
elif wanted_ext == '.mobi' and ext == '.epub':
filename = os.path.abspath(wanted_root + ext)
@@ -1085,10 +1102,10 @@ def getOutputFilename(srcpath, wantedname, ext, tomenumber):
filename = source_path.with_name(name)
else:
filename = os.path.splitext(srcpath)[0] + tomenumber + ext
if os.path.isfile(filename):
if os.path.exists(filename):
counter = 0
basename = os.path.splitext(filename)[0]
while os.path.isfile(basename + '_kcc' + str(counter) + ext):
while os.path.exists(basename + '_kcc' + str(counter) + ext):
counter += 1
filename = basename + '_kcc' + str(counter) + ext
elif options.format == 'MOBI' and ext == '.epub':
@@ -1222,7 +1239,7 @@ def removeNonImages(filetree):
raise RuntimeError('\n'.join(warning))
def sanitizeTree(filetree, prefix='kcc'):
def sanitizeTree(filetree, options, prefix='kcc'):
chapterNames = {}
page = 1
cover_path = None
@@ -1247,7 +1264,7 @@ def sanitizeTree(filetree, prefix='kcc'):
dirs.sort(key=OS_SORT_KEY)
for i, name in enumerate(dirs):
tmpName = name
slugified = slugify(name, is_natural_sorted)
slugified = slugify(name, options, is_natural_sorted)
while os.path.exists(os.path.join(root, slugified)) and name.upper() != slugified.upper():
slugified += "A"
chapterNames[slugified] = tmpName
@@ -1410,7 +1427,7 @@ def createNewTome(parent):
return tomePath, tomePathRoot
def slugify(value, is_natural_sorted):
def slugify(value, options, is_natural_sorted):
if options.format == 'CBZ' and is_natural_sorted:
return value
if options.format != 'CBZ':
@@ -1422,6 +1439,9 @@ def slugify(value, is_natural_sorted):
return value
def makeZIP(zipfilename, basedir, job_progress='', isepub=False):
if options.folder_output:
move(basedir, zipfilename)
return zipfilename
start = perf_counter()
if SEVENZIP in available_archive_tools():
if isepub:
@@ -1467,6 +1487,8 @@ def makeParser():
help="Manga style (right-to-left reading and splitting)")
main_options.add_argument("--lightnovel", action="store_true", dest="lightnovel", default=False,
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,
help="Force EBOK tag instead of PDOC for MOBI")
main_options.add_argument("--invertdirection", action="store_true", dest="invertdirection", default=False,
@@ -1631,6 +1653,12 @@ def checkOptions(options):
options.keep_epub = True
options.format = 'MOBI'
options.kfx = False
options.skip_zip = False
options.folder_output = False
if options.format == 'FOLDER':
options.format = 'CBZ'
options.skip_zip = True
options.folder_output = True
if options.format == 'Auto':
if options.profile in ['KDX']:
options.format = 'CBZ'
@@ -1775,10 +1803,10 @@ def makeFusion(sources: List[str]):
else:
targetpath = fusion_path.joinpath(f'{prefix}{source_path.name}')
path = getWorkFolder(source, str(targetpath))
path = getWorkFolder(source, options, str(targetpath))
if path != str(targetpath):
move(os.path.join(path, 'OEBPS', 'Images'), targetpath)
sanitizeTree(targetpath, prefix='fusion')
sanitizeTree(targetpath, options, prefix='fusion')
# TODO: remove flattenTree when subchapters are supported
flattenTree(targetpath)
@@ -1801,8 +1829,9 @@ def makeBook(source, qtgui=None, job_progress=''):
if not options.filefusion:
checkPre('LLL-')
print(f"{job_progress}Preparing source images...")
path = getWorkFolder(source)
path = getWorkFolder(source, options)
print(f"{job_progress}Checking images...")
_, ext = os.path.splitext(source)
if options.lightnovel:
for root, _, files in os.walk(os.path.join(path, 'OEBPS', 'Images')):
@@ -1823,7 +1852,6 @@ def makeBook(source, qtgui=None, job_progress=''):
if img.size[0] > x or img.size[1] > y:
img = ImageOps.contain(img, (x, y))
img.save(os.path.join(root, file), quality=options.jpegquality)
_, ext = os.path.splitext(source)
if ext != '.epub':
ext = '.cbz'
output_file = getOutputFilename(source, options.output, ext, '')
@@ -1835,10 +1863,56 @@ def makeBook(source, qtgui=None, job_progress=''):
getMetadata(os.path.join(path, "OEBPS", "Images"), source)
removeNonImages(os.path.join(path, "OEBPS", "Images"))
detectSuboptimalProcessing(os.path.join(path, "OEBPS", "Images"), source)
chapterNames, cover_path = sanitizeTree(os.path.join(path, 'OEBPS', 'Images'))
chapterNames, cover_path = sanitizeTree(os.path.join(path, 'OEBPS', 'Images'), options)
if os.path.exists(source+'.json'):
flattenTree(os.path.join(path, 'OEBPS', 'Images'))
chapterNames = {}
cover_path = None
with open(source+'.json') as f:
data = json.load(f)
for root, _, files in os.walk(os.path.join(path, 'OEBPS', 'Images')):
sorted_files = os_sorted(files)
for i in range(len(sorted_files)):
if not cover_path:
cover_path = os.path.join(root, sorted_files[i])
if i in data['spreads']:
im1 = Image.open(os.path.join(root, sorted_files[i]))
im2 = Image.open(os.path.join(root, sorted_files[i+1]))
if not options.righttoleft:
im1, im2 = im2, im1
dst = Image.new('RGB', (im1.width + im2.width, im1.height))
dst.paste(im2, (0, 0))
dst.paste(im1, (im1.width, 0))
base, _ = os.path.splitext(os.path.basename(sorted_files[i]))
dst.save(os.path.join(path, 'OEBPS', 'Images', f'{base}-merged.png'))
os.remove(os.path.join(root, sorted_files[i]))
os.remove(os.path.join(root, sorted_files[i+1]))
if not os.path.exists(cover_path):
cover_path = os.path.join(root, f'{base}-merged.png')
if options.filefusion:
# Strip the fusion_0001_ sort prefix from makeFusion if present
chapterNames = {k: sub(r'^fusion_\d{4}_', '', v) for k, v in chapterNames.items()}
source_path = Path(source)
options.customcover = False
if source_path.parent.joinpath('Covers').is_dir():
series = os_sorted(filter(lambda s: s.endswith(ext) and '_kcc' not in s, os.listdir(source_path.parent)))
source_index = series.index(os.path.basename(source))
covers = os.listdir(source_path.parent.joinpath('Covers'))
filtered_covers = []
for cover in covers:
_, cover_ext = getImageFileName(cover)
if cover_ext in IMAGE_TYPES:
filtered_covers.append(cover)
sorted_covers = os_sorted(filtered_covers)
try:
cover_path = source_path.parent.joinpath('Covers', sorted_covers[source_index])
options.customcover = True
except IndexError:
pass
cover = None
if not options.webtoon:
cover = image.Cover(cover_path, options)
@@ -1920,7 +1994,7 @@ def makeBook(source, qtgui=None, job_progress=''):
filepath.append(getOutputFilename(source, options.output, '.cbz', ' ' + str(tomeNumber)))
else:
filepath.append(getOutputFilename(source, options.output, '.cbz', ''))
if cover and cover.smartcover:
if cover and (cover.smartcover or options.customcover):
cover.save_to_folder(os.path.join(tome, 'OEBPS', 'Images', '##cover.jpg'), tomeNumber, len(tomes))
if options.comicinfo_xml:
with open(os.path.join(tome, 'OEBPS', 'Images', 'ComicInfo.xml'), 'wb') as xmlOutput:
@@ -1931,7 +2005,7 @@ def makeBook(source, qtgui=None, job_progress=''):
# determine output filename based on source and tome count
suffix = (' ' + str(tomeNumber)) if len(tomes) > 1 else ''
output_file = getOutputFilename(source, options.output, '.pdf', suffix)
if cover and cover.smartcover:
if cover and (cover.smartcover or options.customcover):
cover.save_to_folder(os.path.join(tome, 'OEBPS', 'Images', 'cover.jpg'), tomeNumber, len(tomes))
# use optimized buildPDF logic with streaming and compression
output_pdf = buildPDF(tome, options.title, job_progress, None, output_file)
+2
View File
@@ -112,6 +112,8 @@ def splitImage(work):
imgProcess = imgEdges.point(lambda p: 255 if p > 6 else 0).convert('1', dither=Dither.NONE)
widthImg, heightImg = imgOrg.size
if widthImg < 300:
raise UserWarning('PDF render failed < 300 px. Try legacy extract option instead.')
if heightImg > opt.height:
if opt.debug:
drawImg = Image.open(filePath).convert(mode='RGBA')
+5 -1
View File
@@ -513,7 +513,9 @@ class ComicPage:
self.image = erase_rainbow_artifacts(self.image, is_color)
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
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)
@@ -536,6 +538,8 @@ class ComicPage:
self.image = ImageOps.pad(self.image, self.opt.kfx_resolution, method=method, color=self.fill)
elif self.opt.stretch:
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:
pass
else: # if image bigger than device resolution or smaller with upscaling