1
0
mirror of https://github.com/ciromattia/kcc synced 2026-05-27 01:42:09 +00:00

Added a bunch of optimizations (autocontrast, page centering)

This commit is contained in:
Ciro Mattia Gonano
2013-01-17 16:20:32 +01:00
parent df752eb110
commit f231e9112a
4 changed files with 102 additions and 62 deletions

View File

@@ -1,32 +1,34 @@
# KindleComicConverter
`KindleComicConverter` is a Python app which aim is to convert comic files or folders to a comic-type (Mobipocket) ebook to take advantage of the new Panel View mode on Amazon's Kindle.
It also optimizes comic images by:
- enhancing contrast
- cutting page numbering
- cropping white borders
- resizing larger images to device's native resolution
- quantizing images to device's palette
## INPUT FORMATS
`kcc` can understand and convert, at the moment, the following file types:
- CBZ, ZIP
- CBR, RAR
- CBR, RAR *(with `unrar` executable)*
- flat folders
- PDF *(extracting only contained JPG images)*
- PDF *(extracting only contained JPG images)*
For now the script does not understand folder depth, so it will work on flat folders/archives only.
## REQUIREMENTS
- `kindlegen` in /usr/local/bin/
- [unrar](http://www.rarlab.com/download.htm) and [rarfile.py](http://developer.berlios.de/project/showfiles.php?group_id=5373&release_id=18844) for `calibre2ebook.py` automatic CBR extracting.
- [unrar](http://www.rarlab.com/download.htm) CBR support.
### for compiling/running from source:
- Python 2.7+ (included in MacOS and Linux, follow the [official documentation](http://www.python.org/getit/windows/) to install on Windows)
- You are strongly encouraged to get the [Python Imaging Library](http://www.pythonware.com/products/pil/) that, altough optional, provides a bunch of comic optimizations like split double pages, resize to optimal resolution, improve contrast and palette, etc.
- [Python Imaging Library](http://www.pythonware.com/products/pil/) for comic optimizations like split double pages, resize to optimal resolution, improve contrast and palette, etc.
Please refer to official documentation for installing into your system.
## USAGE
Drop a folder or a CBZ/CBR file over the app, after a while you'll get a comic-type .mobi to sideload on your Kindle.
The script takes care of calling `comic2ebook.py`, `kindlegen` and `kindlestrip.py`.
> **WARNING:** at the moment the droplet *ALWAYS* uses the **KHD** profile (*Kindle Paperwhite*).
> If you want to specify other profiles, please use the script from command line.
### standalone `comic2ebook.py` usage:
### Standalone `comic2ebook.py` usage:
```
comic2ebook.py [options] comic_file|comic_folder
@@ -34,18 +36,32 @@ comic2ebook.py [options] comic_file|comic_folder
--version show program's version number and exit
-h, --help show this help message and exit
-p PROFILE, --profile=PROFILE
Device profile (choose one among K1, K2, K3, K4, KHD
[default])
Device profile (choose one among K1, K2, K3, K4, KDX, KDXG or KHD) [default=KHD]
-t TITLE, --title=TITLE
Comic title
-m, --manga-style Split pages 'manga style' (right-to-left reading)
Comic title [default=filename]
-m, --manga-style Split pages 'manga style' (right-to-left reading) [default=False]
-v, --verbose Verbose output [default=False]
-i, --image-processing
Apply image preprocessing (page splitting and optimizations) [default=True]
--upscale-images Resize images smaller than device's resolution [default=False]
--stretch-images Stretch images to device's resolution [default=False]
--cut-page-numbers Try to cut page numbering on images [default=True]
```
The script takes care of unzipping/unrarring the file if it's an archive, creating a directory of images which should be then filled with a `.opf`, `.ncx`, and many `.html` files, then:
1. Run `Kindlegen` on `content.opf`. Depending on how many images you have, this may take awhile. Once completed, the `.mobi` file should be in the directory.
2. Remove the SRCS record to reduce the `.mobi` filesize in half. You can use [Kindlestrip](http://www.mobileread.com/forums/showthread.php?t=96903).
2. (optionally) remove the SRCS record to reduce the `.mobi` filesize in half. You can use [Kindlestrip](http://www.mobileread.com/forums/showthread.php?t=96903).
3. Copy the `.mobi` file to your Kindle!
### AppleScript Droplet (may be outdated)
Drop a folder or a CBZ/CBR file over the app, after a while you'll get a comic-type .mobi to sideload on your Kindle.
The script takes care of calling `comic2ebook.py`, `kindlegen` and `kindlestrip.py`.
> **WARNING:** at the moment the droplet *ALWAYS* uses the **KHD** profile (*Kindle Paperwhite*).
> If you want to specify other profiles, please use the script from command line.
## CREDITS
This script born as a cross-platform alternative to `KindleComicParser` by **Dc5e** (published in [this mobileread forum thread](http://www.mobileread.com/forums/showthread.php?t=192783))
@@ -71,13 +87,14 @@ and installed in `/usr/local/bin/`
WARNING: PIL is required for all image mangling!
- 1.30 - Fixed an issue in OPF generation for device resolution
Reworked options system (call with -h option to get the inline help)
- 1.40 - Added some options for controlling image optimization
Further optimization (ImageOps, page numbering cut, autocontrast)
- 2.00 - GUI! AppleScript is gone and Tk is used to provide cross-platform GUI support.
## TODO
- Add gracefully exit for CBR if no rarfile.py and no unrar executable are found
- Improve error reporting
- Recurse into dirtree for multiple comics
- Support pages extraction from PDF files
## COPYRIGHT