mirror of
https://github.com/ciromattia/kcc
synced 2026-04-15 13:38:46 +00:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6fdfddd7d9 | ||
|
|
34fb68ac65 | ||
|
|
b4d72cd581 | ||
|
|
1dead9af8f | ||
|
|
b42f05686e | ||
|
|
adf48d24f9 | ||
|
|
723fa4c0b8 | ||
|
|
2632d18e2c | ||
|
|
94e4937566 | ||
|
|
f7ce1cf271 | ||
|
|
ab93c03838 | ||
|
|
541b1d876b | ||
|
|
d189f9909d | ||
|
|
1dce4f8d2c | ||
|
|
58aab0cb65 | ||
|
|
d2dc089c62 | ||
|
|
3660f2370f | ||
|
|
87c6e3a35e | ||
|
|
981c556550 | ||
|
|
123d603cbd | ||
|
|
a344dd73bf | ||
|
|
095694e9cf | ||
|
|
4b4860b976 | ||
|
|
56e8e24176 | ||
|
|
b0f8f1c633 | ||
|
|
38acc3bf05 | ||
|
|
fbd5980b9b | ||
|
|
667d702b8a | ||
|
|
9a4143ce62 | ||
|
|
f63387cae4 | ||
|
|
f5fd2bb7fe |
4
.github/workflows/package-linux.yml
vendored
4
.github/workflows/package-linux.yml
vendored
@@ -35,7 +35,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y libpng-dev libjpeg-dev p7zip-full p7zip-rar python3-pip squashfs-tools libfuse2 libxcb-cursor0
|
sudo apt-get install -y libpng-dev libjpeg-dev p7zip-full p7zip-rar python3-pip squashfs-tools libfuse2 libxcb-cursor0
|
||||||
python -m pip install --upgrade pip setuptools wheel certifi pyinstaller --no-binary pyinstaller
|
python -m pip install --upgrade pip certifi pyinstaller --no-binary pyinstaller
|
||||||
python -m pip install -r requirements.txt
|
python -m pip install -r requirements.txt
|
||||||
- name: build binary
|
- name: build binary
|
||||||
run: |
|
run: |
|
||||||
@@ -68,7 +68,7 @@ jobs:
|
|||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
prerelease: true
|
prerelease: true
|
||||||
generate_release_notes: true
|
generate_release_notes: false
|
||||||
files: |
|
files: |
|
||||||
LICENSE.txt
|
LICENSE.txt
|
||||||
*.AppImage*
|
*.AppImage*
|
||||||
|
|||||||
4
.github/workflows/package-macos.yml
vendored
4
.github/workflows/package-macos.yml
vendored
@@ -38,7 +38,7 @@ jobs:
|
|||||||
cache: 'pip'
|
cache: 'pip'
|
||||||
- name: Install python dependencies
|
- name: Install python dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip setuptools wheel pyinstaller certifi
|
python -m pip install --upgrade pip pyinstaller certifi
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
- name: Install the Apple certificate and provisioning profile
|
- name: Install the Apple certificate and provisioning profile
|
||||||
# TODO signing
|
# TODO signing
|
||||||
@@ -89,7 +89,7 @@ jobs:
|
|||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
prerelease: true
|
prerelease: true
|
||||||
generate_release_notes: true
|
generate_release_notes: false
|
||||||
files: |
|
files: |
|
||||||
dist/*.dmg
|
dist/*.dmg
|
||||||
- name: Clean up keychain and provisioning profile
|
- name: Clean up keychain and provisioning profile
|
||||||
|
|||||||
4
.github/workflows/package-osx-legacy.yml
vendored
4
.github/workflows/package-osx-legacy.yml
vendored
@@ -40,7 +40,7 @@ jobs:
|
|||||||
- name: Install Python dependencies
|
- name: Install Python dependencies
|
||||||
run: |
|
run: |
|
||||||
python3 --version
|
python3 --version
|
||||||
pip3 install --upgrade pip setuptools wheel pyinstaller certifi
|
pip3 install --upgrade pip pyinstaller certifi
|
||||||
pip3 install --upgrade -r requirements-osx-legacy.txt
|
pip3 install --upgrade -r requirements-osx-legacy.txt
|
||||||
./gen_ui_files.sh
|
./gen_ui_files.sh
|
||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v6
|
||||||
@@ -60,7 +60,7 @@ jobs:
|
|||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
prerelease: true
|
prerelease: true
|
||||||
generate_release_notes: true
|
generate_release_notes: false
|
||||||
files: |
|
files: |
|
||||||
LICENSE.txt
|
LICENSE.txt
|
||||||
dist/*.dmg
|
dist/*.dmg
|
||||||
|
|||||||
4
.github/workflows/package-windows.yml
vendored
4
.github/workflows/package-windows.yml
vendored
@@ -45,7 +45,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
PYINSTALLER_COMPILE_BOOTLOADER: 1
|
PYINSTALLER_COMPILE_BOOTLOADER: 1
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip setuptools wheel
|
python -m pip install --upgrade pip
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
pip install certifi pyinstaller --no-binary pyinstaller
|
pip install certifi pyinstaller --no-binary pyinstaller
|
||||||
- name: build binary
|
- name: build binary
|
||||||
@@ -73,6 +73,6 @@ jobs:
|
|||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
prerelease: true
|
prerelease: true
|
||||||
generate_release_notes: true
|
generate_release_notes: false
|
||||||
files: |
|
files: |
|
||||||
dist/*.exe
|
dist/*.exe
|
||||||
|
|||||||
4
.github/workflows/package-windows7.yml
vendored
4
.github/workflows/package-windows7.yml
vendored
@@ -37,7 +37,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
PYINSTALLER_COMPILE_BOOTLOADER: 1
|
PYINSTALLER_COMPILE_BOOTLOADER: 1
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip setuptools wheel
|
python -m pip install --upgrade pip
|
||||||
pip install -r requirements-win7.txt
|
pip install -r requirements-win7.txt
|
||||||
pip install certifi pyinstaller --no-binary pyinstaller
|
pip install certifi pyinstaller --no-binary pyinstaller
|
||||||
.\gen_ui_files.bat
|
.\gen_ui_files.bat
|
||||||
@@ -55,6 +55,6 @@ jobs:
|
|||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
prerelease: true
|
prerelease: true
|
||||||
generate_release_notes: true
|
generate_release_notes: false
|
||||||
files: |
|
files: |
|
||||||
dist/*.exe
|
dist/*.exe
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ FROM python:3.13-slim-bullseye AS builder
|
|||||||
|
|
||||||
# Install system dependencies
|
# Install system dependencies
|
||||||
RUN set -x && \
|
RUN set -x && \
|
||||||
BUILD_DEPS="build-essential cmake libffi-dev libfreetype6-dev libfontconfig1-dev libpng-dev libjpeg-dev libssl-dev libxft-dev make python3-dev python3-setuptools python3-wheel" && \
|
BUILD_DEPS="build-essential cmake libffi-dev libfreetype6-dev libfontconfig1-dev libpng-dev libjpeg-dev libssl-dev libxft-dev make python3-dev" && \
|
||||||
RUNTIME_DEPS="bash ca-certificates chrpath locales locales-all libfreetype6 libfontconfig1 p7zip-full python3 python3-pip libgl1" && \
|
RUNTIME_DEPS="bash ca-certificates chrpath locales locales-all libfreetype6 libfontconfig1 p7zip-full python3 python3-pip libgl1" && \
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get update -y && \
|
DEBIAN_FRONTEND=noninteractive apt-get update -y && \
|
||||||
apt-get install -y --no-install-recommends ${BUILD_DEPS} ${RUNTIME_DEPS}
|
apt-get install -y --no-install-recommends ${BUILD_DEPS} ${RUNTIME_DEPS}
|
||||||
|
|||||||
16
README.md
16
README.md
@@ -13,6 +13,13 @@ Pages display in fullscreen without margins,
|
|||||||
with proper fixed layout support.
|
with proper fixed layout support.
|
||||||
Supported input formats include JPG/PNG image files in folders, archives, or PDFs.
|
Supported input formats include JPG/PNG image files in folders, archives, or PDFs.
|
||||||
Supported output formats include MOBI/AZW3, EPUB, KEPUB, CBZ, and PDF.
|
Supported output formats include MOBI/AZW3, EPUB, KEPUB, CBZ, and PDF.
|
||||||
|
KCC runs on Windows, macOS, and Linux.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
**NEW**: PDF output is now supported for direct conversion to reMarkable devices!
|
**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
|
When using a reMarkable profile (Rmk1, Rmk2, RmkPP), the format automatically defaults to PDF
|
||||||
@@ -34,6 +41,7 @@ KCC avoids many common formatting issues (some of which occur [even on the Kindl
|
|||||||
3) Not utilizing the full 1860x2480 resolution of the 10" Kindle Scribe
|
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
|
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
|
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
|
||||||
|
|
||||||
The GUI looks like this, built in Qt6, with my most commonly used settings:
|
The GUI looks like this, built in Qt6, with my most commonly used settings:
|
||||||
|
|
||||||
@@ -46,7 +54,9 @@ You can change the default output directory by holding `Shift` while clicking th
|
|||||||
Then just drag and drop the generated output files onto your device's documents folder via USB.
|
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.
|
||||||
|
|
||||||
YouTube tutorial (please subscribe): https://www.youtube.com/watch?v=IR2Fhcm9658
|
YouTube tutorial (please subscribe): https://www.youtube.com/watch?v=QQ6zJcMF2Iw
|
||||||
|
|
||||||
|
Installation tutorial: https://www.youtube.com/watch?v=IR2Fhcm9658
|
||||||
|
|
||||||
### A word of warning
|
### 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.
|
**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.
|
||||||
@@ -98,7 +108,7 @@ There are also legacy macOS 10.14+ and Windows 7 experimental versions available
|
|||||||
|
|
||||||
The `c2e` and `c2p` versions are command line tools for power users.
|
The `c2e` and `c2p` versions are command line tools for power users.
|
||||||
|
|
||||||
On Mac, follow: https://support.apple.com/guide/mac-help/open-a-mac-app-from-an-unknown-developer-mh40616/mac
|
On macOS, if you get a `can't be opened` error, follow: https://support.apple.com/guide/mac-help/open-a-mac-app-from-an-unknown-developer-mh40616/mac
|
||||||
|
|
||||||
For flatpak, Docker, and AppImage versions, refer to the wiki: https://github.com/ciromattia/kcc/wiki/Installation
|
For flatpak, Docker, and AppImage versions, refer to the wiki: https://github.com/ciromattia/kcc/wiki/Installation
|
||||||
|
|
||||||
@@ -238,6 +248,7 @@ MAIN:
|
|||||||
|
|
||||||
PROCESSING:
|
PROCESSING:
|
||||||
-n, --noprocessing Do not modify image and ignore any profile or processing option
|
-n, --noprocessing Do not modify image and ignore any profile or processing option
|
||||||
|
--pdfextract Use legacy PDF image extraction method from KCC 8 and earlier.
|
||||||
-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
|
||||||
-r SPLITTER, --splitter SPLITTER
|
-r SPLITTER, --splitter SPLITTER
|
||||||
@@ -258,6 +269,7 @@ PROCESSING:
|
|||||||
Crop empty sections. 0: Disabled 1: Horizontally 2: Both [Default=0]
|
Crop empty sections. 0: Disabled 1: Horizontally 2: Both [Default=0]
|
||||||
--blackborders Disable autodetection and force black borders
|
--blackborders Disable autodetection and force black borders
|
||||||
--whiteborders Disable autodetection and force white borders
|
--whiteborders Disable autodetection and force white borders
|
||||||
|
--coverfill Center-crop only the cover to fill target device screen
|
||||||
--forcecolor Don't convert images to grayscale
|
--forcecolor Don't convert images to grayscale
|
||||||
--forcepng Create PNG files instead JPEG
|
--forcepng Create PNG files instead JPEG
|
||||||
--mozjpeg Create JPEG files using mozJpeg
|
--mozjpeg Create JPEG files using mozJpeg
|
||||||
|
|||||||
26
gui/KCC.ui
26
gui/KCC.ui
@@ -473,7 +473,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QSpinBox" name="chunkSizeBox">
|
<widget class="QSpinBox" name="chunkSizeBox">
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<number>100</number>
|
<number>50</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>600</number>
|
<number>600</number>
|
||||||
@@ -896,6 +896,29 @@ Higher values are larger and higher quality, and may resolve blank page issues.<
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="9" column="0">
|
||||||
|
<widget class="QCheckBox" name="pdfExtractBox">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Use the PDF image extraction method from KCC 8 and earlier.
|
||||||
|
|
||||||
|
Useful for really weird PDFs.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>PDF Legacy Extract</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="9" column="1">
|
||||||
|
<widget class="QCheckBox" name="coverFillBox">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Resize cover to exact device resolution by center-cropping to aspect ratio first.
|
||||||
|
May crop top/bottom or left/right depending on source aspect ratio. Not implemented for Kindle Scribe.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Cover Fill</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -1025,6 +1048,7 @@ Higher values are larger and higher quality, and may resolve blank page issues.<
|
|||||||
<tabstop>noRotateBox</tabstop>
|
<tabstop>noRotateBox</tabstop>
|
||||||
<tabstop>interPanelCropBox</tabstop>
|
<tabstop>interPanelCropBox</tabstop>
|
||||||
<tabstop>metadataTitleBox</tabstop>
|
<tabstop>metadataTitleBox</tabstop>
|
||||||
|
<tabstop>coverFillBox</tabstop>
|
||||||
<tabstop>chunkSizeCheckBox</tabstop>
|
<tabstop>chunkSizeCheckBox</tabstop>
|
||||||
<tabstop>chunkSizeBox</tabstop>
|
<tabstop>chunkSizeBox</tabstop>
|
||||||
<tabstop>eraseRainbowBox</tabstop>
|
<tabstop>eraseRainbowBox</tabstop>
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ from raven import Client
|
|||||||
from tempfile import gettempdir
|
from tempfile import gettempdir
|
||||||
|
|
||||||
from .shared import HTMLStripper, sanitizeTrace, walkLevel, subprocess_run
|
from .shared import HTMLStripper, sanitizeTrace, walkLevel, subprocess_run
|
||||||
from .comicarchive import SEVENZIP, available_archive_tools
|
from .comicarchive import SEVENZIP, TAR, available_archive_tools
|
||||||
from . import __version__
|
from . import __version__
|
||||||
from . import comic2ebook
|
from . import comic2ebook
|
||||||
from . import metadata
|
from . import metadata
|
||||||
@@ -327,6 +327,10 @@ class WorkerThread(QThread):
|
|||||||
options.maximizestrips = True
|
options.maximizestrips = True
|
||||||
if GUI.disableProcessingBox.isChecked():
|
if GUI.disableProcessingBox.isChecked():
|
||||||
options.noprocessing = True
|
options.noprocessing = True
|
||||||
|
if GUI.pdfExtractBox.isChecked():
|
||||||
|
options.pdfextract = True
|
||||||
|
if GUI.coverFillBox.isChecked():
|
||||||
|
options.coverfill = True
|
||||||
if GUI.metadataTitleBox.checkState() == Qt.CheckState.PartiallyChecked:
|
if GUI.metadataTitleBox.checkState() == Qt.CheckState.PartiallyChecked:
|
||||||
options.metadatatitle = 1
|
options.metadatatitle = 1
|
||||||
elif GUI.metadataTitleBox.checkState() == Qt.CheckState.Checked:
|
elif GUI.metadataTitleBox.checkState() == Qt.CheckState.Checked:
|
||||||
@@ -521,6 +525,7 @@ class WorkerThread(QThread):
|
|||||||
if os.path.exists(item.replace('.epub', '.mobi')):
|
if os.path.exists(item.replace('.epub', '.mobi')):
|
||||||
os.remove(item.replace('.epub', '.mobi'))
|
os.remove(item.replace('.epub', '.mobi'))
|
||||||
MW.addMessage.emit('KindleGen failed to create MOBI!', 'error', False)
|
MW.addMessage.emit('KindleGen failed to create MOBI!', 'error', False)
|
||||||
|
MW.addMessage.emit(self.kindlegenErrorCode[1], 'error', False)
|
||||||
MW.addTrayMessage.emit('KindleGen failed to create MOBI!', 'Critical')
|
MW.addTrayMessage.emit('KindleGen failed to create MOBI!', 'Critical')
|
||||||
if self.kindlegenErrorCode[0] == 1 and self.kindlegenErrorCode[1] != '':
|
if self.kindlegenErrorCode[0] == 1 and self.kindlegenErrorCode[1] != '':
|
||||||
MW.showDialog.emit("KindleGen error:\n\n" + self.kindlegenErrorCode[1], 'error')
|
MW.showDialog.emit("KindleGen error:\n\n" + self.kindlegenErrorCode[1], 'error')
|
||||||
@@ -1032,9 +1037,12 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
|
|||||||
'colorBox': GUI.colorBox.checkState(),
|
'colorBox': GUI.colorBox.checkState(),
|
||||||
'eraseRainbowBox': GUI.eraseRainbowBox.checkState(),
|
'eraseRainbowBox': GUI.eraseRainbowBox.checkState(),
|
||||||
'disableProcessingBox': GUI.disableProcessingBox.checkState(),
|
'disableProcessingBox': GUI.disableProcessingBox.checkState(),
|
||||||
|
'pdfExtractBox': GUI.pdfExtractBox.checkState(),
|
||||||
|
'coverFillBox': GUI.coverFillBox.checkState(),
|
||||||
'metadataTitleBox': GUI.metadataTitleBox.checkState(),
|
'metadataTitleBox': GUI.metadataTitleBox.checkState(),
|
||||||
'mozJpegBox': GUI.mozJpegBox.checkState(),
|
'mozJpegBox': GUI.mozJpegBox.checkState(),
|
||||||
'jpegQualityBox': GUI.jpegQualityBox.checkState(),
|
'jpegQualityBox': GUI.jpegQualityBox.checkState(),
|
||||||
|
'jpegQuality': GUI.jpegQualitySpinBox.value(),
|
||||||
'widthBox': GUI.widthBox.value(),
|
'widthBox': GUI.widthBox.value(),
|
||||||
'heightBox': GUI.heightBox.value(),
|
'heightBox': GUI.heightBox.value(),
|
||||||
'deleteBox': GUI.deleteBox.checkState(),
|
'deleteBox': GUI.deleteBox.checkState(),
|
||||||
@@ -1086,7 +1094,8 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
|
|||||||
if message[-1] == '/':
|
if message[-1] == '/':
|
||||||
message = message[:-1]
|
message = message[:-1]
|
||||||
self.handleMessage(message)
|
self.handleMessage(message)
|
||||||
GUI.jobList.sortItems()
|
# sorting may conflict with manual file fusion order
|
||||||
|
# GUI.jobList.sortItems()
|
||||||
|
|
||||||
def forceShutdown(self):
|
def forceShutdown(self):
|
||||||
self.saveSettings(None)
|
self.saveSettings(None)
|
||||||
@@ -1173,6 +1182,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
|
|||||||
"EPUB": {'icon': 'EPUB', 'format': 'EPUB'},
|
"EPUB": {'icon': 'EPUB', 'format': 'EPUB'},
|
||||||
"CBZ": {'icon': 'CBZ', 'format': 'CBZ'},
|
"CBZ": {'icon': 'CBZ', 'format': 'CBZ'},
|
||||||
"PDF": {'icon': 'EPUB', 'format': 'PDF'},
|
"PDF": {'icon': 'EPUB', 'format': 'PDF'},
|
||||||
|
"PDF (200MB limit)": {'icon': 'EPUB', 'format': 'PDF-200MB'},
|
||||||
"KFX (does not work)": {'icon': 'KFX', 'format': 'KFX'},
|
"KFX (does not work)": {'icon': 'KFX', 'format': 'KFX'},
|
||||||
"MOBI + EPUB": {'icon': 'MOBI', 'format': 'MOBI+EPUB'},
|
"MOBI + EPUB": {'icon': 'MOBI', 'format': 'MOBI+EPUB'},
|
||||||
"EPUB (200MB limit)": {'icon': 'EPUB', 'format': 'EPUB-200MB'},
|
"EPUB (200MB limit)": {'icon': 'EPUB', 'format': 'EPUB-200MB'},
|
||||||
@@ -1195,6 +1205,9 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
|
|||||||
"Kindle 1920x1920": {
|
"Kindle 1920x1920": {
|
||||||
'PVOptions': True, 'ForceExpert': False, 'DefaultFormat': 0, 'DefaultUpscale': False, 'ForceColor': False, 'Label': 'KS1920',
|
'PVOptions': True, 'ForceExpert': False, 'DefaultFormat': 0, 'DefaultUpscale': False, 'ForceColor': False, 'Label': 'KS1920',
|
||||||
},
|
},
|
||||||
|
"Kindle 1240x1860": {
|
||||||
|
'PVOptions': True, 'ForceExpert': False, 'DefaultFormat': 0, 'DefaultUpscale': False, 'ForceColor': False, 'Label': 'KS1240',
|
||||||
|
},
|
||||||
"Kindle Scribe 1/2": {
|
"Kindle Scribe 1/2": {
|
||||||
'PVOptions': True, 'ForceExpert': False, 'DefaultFormat': 0, 'DefaultUpscale': False, 'ForceColor': False, 'Label': 'KS',
|
'PVOptions': True, 'ForceExpert': False, 'DefaultFormat': 0, 'DefaultUpscale': False, 'ForceColor': False, 'Label': 'KS',
|
||||||
},
|
},
|
||||||
@@ -1304,6 +1317,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
|
|||||||
"Separator",
|
"Separator",
|
||||||
"Kindle 1920x1920",
|
"Kindle 1920x1920",
|
||||||
"Kindle 1860x1920",
|
"Kindle 1860x1920",
|
||||||
|
"Kindle 1240x1860",
|
||||||
"Kindle 8/10",
|
"Kindle 8/10",
|
||||||
"Kindle Oasis 8",
|
"Kindle Oasis 8",
|
||||||
"Kindle Paperwhite 7/10",
|
"Kindle Paperwhite 7/10",
|
||||||
@@ -1351,7 +1365,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
|
|||||||
'<a href="https://github.com/ciromattia/kcc/wiki/Important-tips">important tips</a>.',
|
'<a href="https://github.com/ciromattia/kcc/wiki/Important-tips">important tips</a>.',
|
||||||
'info')
|
'info')
|
||||||
|
|
||||||
self.tar = 'tar' in available_archive_tools()
|
self.tar = TAR in available_archive_tools()
|
||||||
self.sevenzip = SEVENZIP in available_archive_tools()
|
self.sevenzip = SEVENZIP in available_archive_tools()
|
||||||
if not any([self.tar, self.sevenzip]):
|
if not any([self.tar, self.sevenzip]):
|
||||||
self.addMessage('<a href="https://github.com/ciromattia/kcc#7-zip">Install 7z (link)</a>'
|
self.addMessage('<a href="https://github.com/ciromattia/kcc#7-zip">Install 7z (link)</a>'
|
||||||
@@ -1433,6 +1447,8 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
|
|||||||
GUI.croppingPowerSlider.setValue(int(self.options[option]))
|
GUI.croppingPowerSlider.setValue(int(self.options[option]))
|
||||||
self.changeCroppingPower(int(self.options[option]))
|
self.changeCroppingPower(int(self.options[option]))
|
||||||
GUI.preserveMarginBox.setValue(self.options.get('preserveMarginBox', 0))
|
GUI.preserveMarginBox.setValue(self.options.get('preserveMarginBox', 0))
|
||||||
|
elif str(option) == "jpegQuality":
|
||||||
|
GUI.jpegQualitySpinBox.setValue(int(self.options[option]))
|
||||||
elif str(option) == "chunkSizeBox":
|
elif str(option) == "chunkSizeBox":
|
||||||
GUI.chunkSizeBox.setValue(int(self.options[option]))
|
GUI.chunkSizeBox.setValue(int(self.options[option]))
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -266,7 +266,7 @@ class Ui_mainWindow(object):
|
|||||||
|
|
||||||
self.chunkSizeBox = QSpinBox(self.chunkSizeWidget)
|
self.chunkSizeBox = QSpinBox(self.chunkSizeWidget)
|
||||||
self.chunkSizeBox.setObjectName(u"chunkSizeBox")
|
self.chunkSizeBox.setObjectName(u"chunkSizeBox")
|
||||||
self.chunkSizeBox.setMinimum(100)
|
self.chunkSizeBox.setMinimum(50)
|
||||||
self.chunkSizeBox.setMaximum(600)
|
self.chunkSizeBox.setMaximum(600)
|
||||||
self.chunkSizeBox.setValue(400)
|
self.chunkSizeBox.setValue(400)
|
||||||
|
|
||||||
@@ -462,6 +462,16 @@ class Ui_mainWindow(object):
|
|||||||
|
|
||||||
self.gridLayout_2.addWidget(self.jpegQualityBox, 8, 0, 1, 1)
|
self.gridLayout_2.addWidget(self.jpegQualityBox, 8, 0, 1, 1)
|
||||||
|
|
||||||
|
self.pdfExtractBox = QCheckBox(self.optionWidget)
|
||||||
|
self.pdfExtractBox.setObjectName(u"pdfExtractBox")
|
||||||
|
|
||||||
|
self.gridLayout_2.addWidget(self.pdfExtractBox, 9, 0, 1, 1)
|
||||||
|
|
||||||
|
self.coverFillBox = QCheckBox(self.optionWidget)
|
||||||
|
self.coverFillBox.setObjectName(u"coverFillBox")
|
||||||
|
|
||||||
|
self.gridLayout_2.addWidget(self.coverFillBox, 9, 1, 1, 1)
|
||||||
|
|
||||||
|
|
||||||
self.gridLayout.addWidget(self.optionWidget, 5, 0, 1, 2)
|
self.gridLayout.addWidget(self.optionWidget, 5, 0, 1, 2)
|
||||||
|
|
||||||
@@ -544,7 +554,8 @@ class Ui_mainWindow(object):
|
|||||||
QWidget.setTabOrder(self.fileFusionBox, self.noRotateBox)
|
QWidget.setTabOrder(self.fileFusionBox, self.noRotateBox)
|
||||||
QWidget.setTabOrder(self.noRotateBox, self.interPanelCropBox)
|
QWidget.setTabOrder(self.noRotateBox, self.interPanelCropBox)
|
||||||
QWidget.setTabOrder(self.interPanelCropBox, self.metadataTitleBox)
|
QWidget.setTabOrder(self.interPanelCropBox, self.metadataTitleBox)
|
||||||
QWidget.setTabOrder(self.metadataTitleBox, self.chunkSizeCheckBox)
|
QWidget.setTabOrder(self.metadataTitleBox, self.coverFillBox)
|
||||||
|
QWidget.setTabOrder(self.coverFillBox, self.chunkSizeCheckBox)
|
||||||
QWidget.setTabOrder(self.chunkSizeCheckBox, self.chunkSizeBox)
|
QWidget.setTabOrder(self.chunkSizeCheckBox, self.chunkSizeBox)
|
||||||
QWidget.setTabOrder(self.chunkSizeBox, self.eraseRainbowBox)
|
QWidget.setTabOrder(self.chunkSizeBox, self.eraseRainbowBox)
|
||||||
QWidget.setTabOrder(self.eraseRainbowBox, self.rotateFirstBox)
|
QWidget.setTabOrder(self.eraseRainbowBox, self.rotateFirstBox)
|
||||||
@@ -733,6 +744,17 @@ class Ui_mainWindow(object):
|
|||||||
"Higher values are larger and higher quality, and may resolve blank page issues.", None))
|
"Higher values are larger and higher quality, and may resolve blank page issues.", None))
|
||||||
#endif // QT_CONFIG(tooltip)
|
#endif // QT_CONFIG(tooltip)
|
||||||
self.jpegQualityBox.setText(QCoreApplication.translate("mainWindow", u"Custom JPEG Quality", None))
|
self.jpegQualityBox.setText(QCoreApplication.translate("mainWindow", u"Custom JPEG Quality", None))
|
||||||
|
#if QT_CONFIG(tooltip)
|
||||||
|
self.pdfExtractBox.setToolTip(QCoreApplication.translate("mainWindow", u"Use the PDF image extraction method from KCC 8 and earlier.\n"
|
||||||
|
"\n"
|
||||||
|
"Useful for really weird PDFs.", None))
|
||||||
|
#endif // QT_CONFIG(tooltip)
|
||||||
|
self.pdfExtractBox.setText(QCoreApplication.translate("mainWindow", u"PDF Legacy Extract", None))
|
||||||
|
#if QT_CONFIG(tooltip)
|
||||||
|
self.coverFillBox.setToolTip(QCoreApplication.translate("mainWindow", u"Resize cover to exact device resolution by center-cropping to aspect ratio first.\n"
|
||||||
|
"May crop top/bottom or left/right depending on source aspect ratio. Not implemented for Kindle Scribe.", None))
|
||||||
|
#endif // QT_CONFIG(tooltip)
|
||||||
|
self.coverFillBox.setText(QCoreApplication.translate("mainWindow", u"Cover Fill", None))
|
||||||
self.gammaLabel.setText(QCoreApplication.translate("mainWindow", u"Gamma: Auto", None))
|
self.gammaLabel.setText(QCoreApplication.translate("mainWindow", u"Gamma: Auto", None))
|
||||||
self.jpegQualityLabel.setText(QCoreApplication.translate("mainWindow", u"JPEG Quality:", None))
|
self.jpegQualityLabel.setText(QCoreApplication.translate("mainWindow", u"JPEG Quality:", None))
|
||||||
# retranslateUi
|
# retranslateUi
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
__version__ = '9.4.2'
|
__version__ = '9.5.1'
|
||||||
__license__ = 'ISC'
|
__license__ = 'ISC'
|
||||||
__copyright__ = '2012-2022, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>, darodi'
|
__copyright__ = '2012-2022, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>, darodi'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ from .comicarchive import SEVENZIP, available_archive_tools
|
|||||||
from . import comic2panel
|
from . import comic2panel
|
||||||
from . import image
|
from . import image
|
||||||
from . import comicarchive
|
from . import comicarchive
|
||||||
|
from . import pdfjpgextract
|
||||||
from . import dualmetafix
|
from . import dualmetafix
|
||||||
from . import metadata
|
from . import metadata
|
||||||
from . import kindle
|
from . import kindle
|
||||||
@@ -659,7 +660,7 @@ def imgDirectoryProcessing(path, job_progress=''):
|
|||||||
raise UserWarning("Conversion interrupted.")
|
raise UserWarning("Conversion interrupted.")
|
||||||
if len(workerOutput) > 0:
|
if len(workerOutput) > 0:
|
||||||
rmtree(os.path.join(path, '..', '..'), True)
|
rmtree(os.path.join(path, '..', '..'), True)
|
||||||
raise RuntimeError("One of workers crashed. Cause: " + workerOutput[0][0], workerOutput[0][1])
|
raise RuntimeError("One of workers crashed. Maybe restart PC. Cause: " + workerOutput[0][0], workerOutput[0][1])
|
||||||
else:
|
else:
|
||||||
rmtree(os.path.join(path, '..', '..'), True)
|
rmtree(os.path.join(path, '..', '..'), True)
|
||||||
raise UserWarning("C2E: Source directory is empty.")
|
raise UserWarning("C2E: Source directory is empty.")
|
||||||
@@ -800,9 +801,7 @@ def extract_page(vector):
|
|||||||
if len(image_list) > 1:
|
if len(image_list) > 1:
|
||||||
raise UserWarning("mupdf_pdf_extract_page_image() function can be used only with single image pages.")
|
raise UserWarning("mupdf_pdf_extract_page_image() function can be used only with single image pages.")
|
||||||
if not image_list:
|
if not image_list:
|
||||||
width, height = int(page.rect.width), int(page.rect.height)
|
continue
|
||||||
blank_page = Image.new("RGB", (width, height), "white")
|
|
||||||
blank_page.save(output_path)
|
|
||||||
else:
|
else:
|
||||||
xref = image_list[0][0]
|
xref = image_list[0][0]
|
||||||
d = doc.extract_image(xref)
|
d = doc.extract_image(xref)
|
||||||
@@ -854,6 +853,7 @@ def mupdf_pdf_process_pages_parallel(filename, output_dir, target_height):
|
|||||||
def getWorkFolder(afile, workdir=None):
|
def getWorkFolder(afile, workdir=None):
|
||||||
if not workdir:
|
if not workdir:
|
||||||
workdir = mkdtemp('', 'KCC-')
|
workdir = mkdtemp('', 'KCC-')
|
||||||
|
# workdir = mkdtemp('', 'KCC-', os.path.dirname(afile))
|
||||||
fullPath = os.path.join(workdir, 'OEBPS', 'Images')
|
fullPath = os.path.join(workdir, 'OEBPS', 'Images')
|
||||||
else:
|
else:
|
||||||
fullPath = workdir
|
fullPath = workdir
|
||||||
@@ -875,6 +875,12 @@ def getWorkFolder(afile, workdir=None):
|
|||||||
os.makedirs(fullPath)
|
os.makedirs(fullPath)
|
||||||
path = workdir
|
path = workdir
|
||||||
sanitizePermissions(path)
|
sanitizePermissions(path)
|
||||||
|
if options.pdfextract:
|
||||||
|
pdf = pdfjpgextract.PdfJpgExtract(afile, fullPath)
|
||||||
|
njpg = pdf.extract()
|
||||||
|
if njpg == 0:
|
||||||
|
raise UserWarning("Failed to extract images from PDF file.")
|
||||||
|
return workdir
|
||||||
target_height = options.profileData[1][1]
|
target_height = options.profileData[1][1]
|
||||||
if options.cropping == 1:
|
if options.cropping == 1:
|
||||||
target_height = target_height + target_height*0.20 #Account for possible margin at the top and bottom
|
target_height = target_height + target_height*0.20 #Account for possible margin at the top and bottom
|
||||||
@@ -957,6 +963,13 @@ def getOutputFilename(srcpath, wantedname, ext, tomenumber):
|
|||||||
while os.path.isfile(basename + '_kcc' + str(counter) + ext):
|
while os.path.isfile(basename + '_kcc' + str(counter) + ext):
|
||||||
counter += 1
|
counter += 1
|
||||||
filename = basename + '_kcc' + str(counter) + ext
|
filename = basename + '_kcc' + str(counter) + ext
|
||||||
|
elif options.format == 'MOBI' and ext == '.epub':
|
||||||
|
counter = 0
|
||||||
|
basename = os.path.splitext(filename)[0]
|
||||||
|
if os.path.isfile(basename + '.mobi'):
|
||||||
|
while os.path.isfile(basename + '_kcc' + str(counter) + '.mobi'):
|
||||||
|
counter += 1
|
||||||
|
filename = basename + '_kcc' + str(counter) + ext
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
|
|
||||||
@@ -1066,7 +1079,7 @@ def removeNonImages(filetree):
|
|||||||
raise UserWarning('No images detected, nested archives are not supported.')
|
raise UserWarning('No images detected, nested archives are not supported.')
|
||||||
|
|
||||||
|
|
||||||
def sanitizeTree(filetree):
|
def sanitizeTree(filetree, prefix='kcc'):
|
||||||
chapterNames = {}
|
chapterNames = {}
|
||||||
page = 1
|
page = 1
|
||||||
cover_path = None
|
cover_path = None
|
||||||
@@ -1076,7 +1089,7 @@ def sanitizeTree(filetree):
|
|||||||
_, ext = getImageFileName(name)
|
_, ext = getImageFileName(name)
|
||||||
|
|
||||||
# 9999 page limit
|
# 9999 page limit
|
||||||
unique_name = f'kcc-{page:04}'
|
unique_name = f'{prefix}-{page:04}'
|
||||||
page += 1
|
page += 1
|
||||||
|
|
||||||
newKey = os.path.join(root, unique_name + ext)
|
newKey = os.path.join(root, unique_name + ext)
|
||||||
@@ -1269,10 +1282,13 @@ def makeZIP(zipfilename, basedir, job_progress='', isepub=False):
|
|||||||
zipfilename = os.path.abspath(zipfilename) + '.zip'
|
zipfilename = os.path.abspath(zipfilename) + '.zip'
|
||||||
if SEVENZIP in available_archive_tools():
|
if SEVENZIP in available_archive_tools():
|
||||||
if isepub:
|
if isepub:
|
||||||
mimetypeFile = open(os.path.join(basedir, 'mimetype'), 'w')
|
mimetypeFile = open(os.path.join(basedir, '!mimetype'), 'w')
|
||||||
mimetypeFile.write('application/epub+zip')
|
mimetypeFile.write('application/epub+zip')
|
||||||
mimetypeFile.close()
|
mimetypeFile.close()
|
||||||
subprocess_run([SEVENZIP, 'a', '-tzip', zipfilename, "*"], capture_output=True, check=True, cwd=basedir)
|
subprocess_run([SEVENZIP, 'a', '-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:
|
else:
|
||||||
zipOutput = ZipFile(zipfilename, 'w', ZIP_DEFLATED)
|
zipOutput = ZipFile(zipfilename, 'w', ZIP_DEFLATED)
|
||||||
if isepub:
|
if isepub:
|
||||||
@@ -1342,6 +1358,10 @@ def makeParser():
|
|||||||
|
|
||||||
processing_options.add_argument("-n", "--noprocessing", action="store_true", dest="noprocessing", default=False,
|
processing_options.add_argument("-n", "--noprocessing", action="store_true", dest="noprocessing", default=False,
|
||||||
help="Do not modify image and ignore any profile or processing option")
|
help="Do not modify image and ignore any profile or processing option")
|
||||||
|
processing_options.add_argument("--pdfextract", action="store_true", dest="pdfextract", default=False,
|
||||||
|
help="Use the legacy PDF image extraction method from KCC 8 and earlier")
|
||||||
|
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,
|
processing_options.add_argument("-u", "--upscale", action="store_true", dest="upscale", default=False,
|
||||||
help="Resize images smaller than device's resolution")
|
help="Resize images smaller than device's resolution")
|
||||||
processing_options.add_argument("-s", "--stretch", action="store_true", dest="stretch", default=False,
|
processing_options.add_argument("-s", "--stretch", action="store_true", dest="stretch", default=False,
|
||||||
@@ -1404,6 +1424,11 @@ def checkOptions(options):
|
|||||||
options.isKobo = False
|
options.isKobo = False
|
||||||
options.bordersColor = None
|
options.bordersColor = None
|
||||||
options.keep_epub = False
|
options.keep_epub = False
|
||||||
|
if options.format == 'PDF-200MB':
|
||||||
|
options.targetsize = 195
|
||||||
|
options.format = 'PDF'
|
||||||
|
if options.batchsplit != 2:
|
||||||
|
options.batchsplit = 1
|
||||||
if options.format == 'EPUB-200MB':
|
if options.format == 'EPUB-200MB':
|
||||||
options.targetsize = 195
|
options.targetsize = 195
|
||||||
options.format = 'EPUB'
|
options.format = 'EPUB'
|
||||||
@@ -1415,6 +1440,8 @@ def checkOptions(options):
|
|||||||
options.format = 'MOBI'
|
options.format = 'MOBI'
|
||||||
if options.batchsplit != 2:
|
if options.batchsplit != 2:
|
||||||
options.batchsplit = 1
|
options.batchsplit = 1
|
||||||
|
if not options.targetsize and options.profile.startswith('Rmk'):
|
||||||
|
options.targetsize = 95
|
||||||
if options.format == 'MOBI+EPUB':
|
if options.format == 'MOBI+EPUB':
|
||||||
options.keep_epub = True
|
options.keep_epub = True
|
||||||
options.format = 'MOBI'
|
options.format = 'MOBI'
|
||||||
@@ -1539,17 +1566,26 @@ def makeFusion(sources: List[str]):
|
|||||||
fusion_path = first_path.parent.joinpath(first_path.name + ' [fused]')
|
fusion_path = first_path.parent.joinpath(first_path.name + ' [fused]')
|
||||||
print("Running Fusion")
|
print("Running Fusion")
|
||||||
|
|
||||||
for source in sources:
|
# Check if prefix is needed when user-specified ordering differs from OS natural sorting
|
||||||
|
path_names = [Path(s).stem if Path(s).is_file() else Path(s).name for s in sources]
|
||||||
|
needs_prefix = os_sorted(path_names) != path_names
|
||||||
|
|
||||||
|
for index, source in enumerate(sources, start=1):
|
||||||
print(f"Processing {source}...")
|
print(f"Processing {source}...")
|
||||||
checkPre(source)
|
checkPre(source)
|
||||||
print("Checking images...")
|
print("Checking images...")
|
||||||
source_path = Path(source)
|
source_path = Path(source)
|
||||||
|
# Add the fusion_0001_ prefix to maintain user-specified order if needed
|
||||||
|
prefix = ''
|
||||||
|
if needs_prefix:
|
||||||
|
prefix = f'fusion_{index:04d}_'
|
||||||
if source_path.is_file():
|
if source_path.is_file():
|
||||||
targetpath = fusion_path.joinpath(source_path.stem)
|
targetpath = fusion_path.joinpath(f'{prefix}{source_path.stem}')
|
||||||
else:
|
else:
|
||||||
targetpath = fusion_path.joinpath(source_path.name)
|
targetpath = fusion_path.joinpath(f'{prefix}{source_path.name}')
|
||||||
|
|
||||||
getWorkFolder(source, str(targetpath))
|
getWorkFolder(source, str(targetpath))
|
||||||
sanitizeTree(targetpath)
|
sanitizeTree(targetpath, prefix='fusion')
|
||||||
# TODO: remove flattenTree when subchapters are supported
|
# TODO: remove flattenTree when subchapters are supported
|
||||||
flattenTree(targetpath)
|
flattenTree(targetpath)
|
||||||
|
|
||||||
@@ -1576,6 +1612,9 @@ def makeBook(source, qtgui=None, job_progress=''):
|
|||||||
removeNonImages(os.path.join(path, "OEBPS", "Images"))
|
removeNonImages(os.path.join(path, "OEBPS", "Images"))
|
||||||
detectSuboptimalProcessing(os.path.join(path, "OEBPS", "Images"), source)
|
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'))
|
||||||
|
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()}
|
||||||
cover = None
|
cover = None
|
||||||
if not options.webtoon:
|
if not options.webtoon:
|
||||||
cover = image.Cover(cover_path, options)
|
cover = image.Cover(cover_path, options)
|
||||||
@@ -1767,4 +1806,3 @@ def makeMOBI(work, qtgui=None):
|
|||||||
makeMOBIWorkerPool.close()
|
makeMOBIWorkerPool.close()
|
||||||
makeMOBIWorkerPool.join()
|
makeMOBIWorkerPool.join()
|
||||||
return makeMOBIWorkerOutput
|
return makeMOBIWorkerOutput
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ from .shared import IMAGE_TYPES, subprocess_run
|
|||||||
|
|
||||||
EXTRACTION_ERROR = 'Failed to extract archive. Try extracting file outside of KCC.'
|
EXTRACTION_ERROR = 'Failed to extract archive. Try extracting file outside of KCC.'
|
||||||
SEVENZIP = '7zz' if platform.system() == 'Darwin' else '7z'
|
SEVENZIP = '7zz' if platform.system() == 'Darwin' else '7z'
|
||||||
|
TAR = 'bsdtar' if platform.system() == 'Linux' else 'tar'
|
||||||
|
|
||||||
|
|
||||||
class ComicArchive:
|
class ComicArchive:
|
||||||
@@ -73,7 +74,7 @@ class ComicArchive:
|
|||||||
missing = []
|
missing = []
|
||||||
|
|
||||||
extraction_commands = [
|
extraction_commands = [
|
||||||
['tar', '--exclude', '__MACOSX', '--exclude', '.DS_Store', '--exclude', 'thumbs.db', '--exclude', 'Thumbs.db', '-xf', self.basename, '-C', targetdir],
|
[TAR, '--exclude', '__MACOSX', '--exclude', '.DS_Store', '--exclude', 'thumbs.db', '--exclude', 'Thumbs.db', '-xf', self.basename, '-C', targetdir],
|
||||||
[SEVENZIP, 'x', '-y', '-xr!__MACOSX', '-xr!.DS_Store', '-xr!thumbs.db', '-xr!Thumbs.db', '-o' + targetdir, self.basename],
|
[SEVENZIP, 'x', '-y', '-xr!__MACOSX', '-xr!.DS_Store', '-xr!thumbs.db', '-xr!Thumbs.db', '-o' + targetdir, self.basename],
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -125,7 +126,7 @@ class ComicArchive:
|
|||||||
def available_archive_tools():
|
def available_archive_tools():
|
||||||
available = []
|
available = []
|
||||||
|
|
||||||
for tool in ['tar', SEVENZIP, 'unar', 'unrar']:
|
for tool in [TAR, SEVENZIP, 'unar', 'unrar']:
|
||||||
try:
|
try:
|
||||||
subprocess_run([tool], stdout=PIPE, stderr=STDOUT)
|
subprocess_run([tool], stdout=PIPE, stderr=STDOUT)
|
||||||
available.append(tool)
|
available.append(tool)
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ class ProfileData:
|
|||||||
'KPW5': ("Kindle Paperwhite 5/Signature Edition", (1236, 1648), Palette16, 1.0),
|
'KPW5': ("Kindle Paperwhite 5/Signature Edition", (1236, 1648), Palette16, 1.0),
|
||||||
'KS1860': ("Kindle 1860", (1860, 1920), Palette16, 1.0),
|
'KS1860': ("Kindle 1860", (1860, 1920), Palette16, 1.0),
|
||||||
'KS1920': ("Kindle 1920", (1920, 1920), Palette16, 1.0),
|
'KS1920': ("Kindle 1920", (1920, 1920), Palette16, 1.0),
|
||||||
|
'KS1240': ("Kindle 1240", (1240, 1860), Palette16, 1.0),
|
||||||
'KS': ("Kindle Scribe 1/2", (1860, 2480), Palette16, 1.0),
|
'KS': ("Kindle Scribe 1/2", (1860, 2480), Palette16, 1.0),
|
||||||
'KCS': ("Kindle Colorsoft", (1264, 1680), Palette16, 1.0),
|
'KCS': ("Kindle Colorsoft", (1264, 1680), Palette16, 1.0),
|
||||||
'KS3': ("Kindle Scribe 3", (1986, 2648), Palette16, 1.0),
|
'KS3': ("Kindle Scribe 3", (1986, 2648), Palette16, 1.0),
|
||||||
@@ -157,7 +158,7 @@ class ComicPageParser:
|
|||||||
|
|
||||||
# Detect corruption in source image, let caller catch any exceptions triggered.
|
# Detect corruption in source image, let caller catch any exceptions triggered.
|
||||||
srcImgPath = os.path.join(source[0], source[1])
|
srcImgPath = os.path.join(source[0], source[1])
|
||||||
Image.open(srcImgPath).verify()
|
# Image.open(srcImgPath).verify()
|
||||||
with Image.open(srcImgPath) as im:
|
with Image.open(srcImgPath) as im:
|
||||||
self.image = im.copy()
|
self.image = im.copy()
|
||||||
|
|
||||||
@@ -568,7 +569,11 @@ class Cover:
|
|||||||
if self.options.kindle_scribe_azw3:
|
if self.options.kindle_scribe_azw3:
|
||||||
size[0] = min(size[0], 1920)
|
size[0] = min(size[0], 1920)
|
||||||
size[1] = min(size[1], 1920)
|
size[1] = min(size[1], 1920)
|
||||||
self.image.thumbnail(tuple(size), Image.Resampling.LANCZOS)
|
if self.options.coverfill and not self.options.kindle_scribe_azw3:
|
||||||
|
# TODO: Kindle Scribe case
|
||||||
|
self.image = ImageOps.fit(self.image, tuple(size), Image.Resampling.LANCZOS, centering=(0.5, 0.5))
|
||||||
|
else:
|
||||||
|
self.image.thumbnail(tuple(size), Image.Resampling.LANCZOS)
|
||||||
|
|
||||||
def crop_main_cover(self):
|
def crop_main_cover(self):
|
||||||
w, h = self.image.size
|
w, h = self.image.size
|
||||||
|
|||||||
@@ -160,6 +160,8 @@ def ignore_pixels_near_edge(bw_img):
|
|||||||
for box in edge_bbox:
|
for box in edge_bbox:
|
||||||
edge = bw_img.crop(box)
|
edge = bw_img.crop(box)
|
||||||
h = edge.histogram()
|
h = edge.histogram()
|
||||||
|
if not edge.height or not edge.width:
|
||||||
|
continue
|
||||||
imperfections = h[255] / (edge.height * edge.width)
|
imperfections = h[255] / (edge.height * edge.width)
|
||||||
if imperfections > 0 and imperfections < .02:
|
if imperfections > 0 and imperfections < .02:
|
||||||
bw_img.paste(im=0, box=box)
|
bw_img.paste(im=0, box=box)
|
||||||
|
|||||||
75
kindlecomicconverter/pdfjpgextract.py
Normal file
75
kindlecomicconverter/pdfjpgextract.py
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# Copyright (c) 2012-2014 Ciro Mattia Gonano <ciromattia@gmail.com>
|
||||||
|
# Copyright (c) 2013-2019 Pawel Jastrzebski <pawelj@iosphe.re>
|
||||||
|
#
|
||||||
|
# Based upon the code snippet by Ned Batchelder
|
||||||
|
# (http://nedbatchelder.com/blog/200712/extracting_jpgs_from_pdfs.html)
|
||||||
|
#
|
||||||
|
# Permission to use, copy, modify, and/or distribute this software for
|
||||||
|
# any purpose with or without fee is hereby granted, provided that the
|
||||||
|
# above copyright notice and this permission notice appear in all
|
||||||
|
# copies.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||||
|
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||||
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
||||||
|
# AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
|
||||||
|
# OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||||
|
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
# PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
#
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
# skip stray images a few pixels in size in some PDFs
|
||||||
|
# typical images are many thousands in length
|
||||||
|
# https://github.com/ciromattia/kcc/pull/546
|
||||||
|
STRAY_IMAGE_LENGTH_THRESHOLD = 300
|
||||||
|
|
||||||
|
|
||||||
|
class PdfJpgExtract:
|
||||||
|
def __init__(self, fname, fullPath):
|
||||||
|
self.fname = fname
|
||||||
|
self.path = fullPath
|
||||||
|
|
||||||
|
def getPath(self):
|
||||||
|
return self.path
|
||||||
|
|
||||||
|
def extract(self):
|
||||||
|
pdf = open(self.fname, "rb").read()
|
||||||
|
startmark = b"\xff\xd8"
|
||||||
|
startfix = 0
|
||||||
|
endmark = b"\xff\xd9"
|
||||||
|
endfix = 2
|
||||||
|
i = 0
|
||||||
|
njpg = 0
|
||||||
|
while True:
|
||||||
|
istream = pdf.find(b"stream", i)
|
||||||
|
if istream < 0:
|
||||||
|
break
|
||||||
|
istart = pdf.find(startmark, istream, istream + 20)
|
||||||
|
if istart < 0:
|
||||||
|
i = istream + 20
|
||||||
|
continue
|
||||||
|
iend = pdf.find(b"endstream", istart)
|
||||||
|
if iend < 0:
|
||||||
|
raise Exception("Didn't find end of stream!")
|
||||||
|
iend = pdf.find(endmark, iend - 20)
|
||||||
|
if iend < 0:
|
||||||
|
raise Exception("Didn't find end of JPG!")
|
||||||
|
istart += startfix
|
||||||
|
iend += endfix
|
||||||
|
i = iend
|
||||||
|
|
||||||
|
if iend - istart < STRAY_IMAGE_LENGTH_THRESHOLD:
|
||||||
|
continue
|
||||||
|
|
||||||
|
jpg = pdf[istart:iend]
|
||||||
|
jpgfile = open(os.path.join(self.path, "jpg%d.jpg" % njpg), "wb")
|
||||||
|
jpgfile.write(jpg)
|
||||||
|
jpgfile.close()
|
||||||
|
njpg += 1
|
||||||
|
|
||||||
|
return njpg
|
||||||
Reference in New Issue
Block a user