1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-13 01:36:27 +00:00
Commit Graph

86 Commits

Author SHA1 Message Date
Alex Xu
cab7cae714 pdf output: margin fill (#1065) 2025-08-14 09:12:45 -07:00
Its-my-right
6a7500441d Prevents rainbow eraser crash on images with 1px dimensions
Don't apply rainbow eraser on images with 1px dimensions
2025-08-06 12:12:21 -07:00
Alex Xu
55193119fb 10% page number crop 2025-07-30 10:39:28 -07:00
Alex Xu
06e2ee2968 ignore 2% of pixels near edges and don't crop more than 10% per edge (#1044)
* max crop and ignore edges

* make edge_bbox neater
2025-07-26 07:26:10 -07:00
Alex Xu
bb70337a35 crop_main_cover ratio adjustment 2025-07-26 07:12:44 -07:00
Its-my-right
cc2eb9dcf3 Feature/rainbow eraser for color images (#1034)
* Add rainbow_artifacts_eraser helper

This helper file contains the methods necessary to perform a fourier transform on the picture, to remove frequencies responsible for rainbow artifacts on Kaleido screens, and performe the reverse fourier transform

* Replace blurring method with frequency removal method to erase rainbow effect on Kaleido 3 screens

* High performance improvements by using rfft2 instead of fft2

* Fine-tuned the settings and added the perpendicular direction for a better final rendering

The finer settings allow for more information to be retained in the final image, while still effectively removing the rainbow effect.

Adding the perpendicular direction results in a better rendering of the final image (avoiding visual artifacts related to suppression at the main angle).

* Revert the addition of perpendicular angles and lower attenuation_factor

It was a mistake to add the perpendicular angles in the previous commit: I had the rainbow effect removal process called 2 times when I did this, for testing purposes (One before downscale and one after downscale).

The proper way to call the process is only after the downscale. And in this case it is not necessary to remove frequencies along the perpendicular angles.

In the mean time, attenuation_factor=0.15 has proven to work well along a collection of testing images.

It should be my latest commit for this feature

* Also attenuate high frequencies at 45°

CFA is sometimes orientated at 135°, sometimes at 45° so until we find if there is a law depending on the screen size, e-reader model or something, the best we can do is attenuate high frequencies on those two directions

* fix imports

* Update comic2ebook.py

Calculate is_color with (opt.forcecolor and img.color)

pass is_color to img.optimizeForDisplay

* Update image.py

Remove color check condition, because now we process colored images too.

Pass is_color to erase_rainbow_artifacts

* Update rainbow_artifacts_eraser.py

Add support for colored images: Convert to YUV, extract luminance channel, do FFT -> Filter -> IFFT on luminance channel, insert back to YUV, convert back to RGB

To maximize compatibility until we know for sure the orientation of CFA for each device, filtering is now done on 135° + 45° axis

After more testing, attenuation_factor is decreased to 0.10

* Update comic2ebook.py

Rename rainbow eraser param

* Update image.py

rename rainbow eraser param

* Update KCC.ui

Rename rainbow eraser checkbox and tooltip

* Update KCC_ui.py

Rename erase rainbow checkbox and tooltip

* Update KCC_gui.py

Rename erase rainbow checkbox and option

* Update README.md

rename erase rainbow param

* Update KCC_gui.py

correct param name for eraserainbow

---------

Co-authored-by: Alex Xu <alexkurosakimh3@gmail.com>
2025-07-18 10:48:56 -07:00
Alex Xu
023797f012 fix imports 2025-07-18 07:38:50 -07:00
Its-my-right
cf047ecf6f Replace blurring method with frequency removal method to erase rainbow effect on Kaleido 3 screens 2025-07-18 07:38:50 -07:00
Alex Xu
6299754964 draft: add black point level (#1028)
* initial black point

* convert to L

* add GUI
2025-07-13 21:52:17 -07:00
Alex Xu
67714a9b06 fix color autocontrast (#1026) 2025-07-11 16:28:19 -07:00
Alex Xu
a79c740387 don't autocontrast color content (#1021) 2025-07-09 13:59:54 -07:00
Alex Xu
dbf8a3ddbd fix ._cover.jpg on macos 15 (#1016) 2025-07-05 07:40:09 -07:00
Alex Xu
8f9e230b62 rotate first (#1015) 2025-07-04 19:52:34 -07:00
Adrian
1fa5a5b19b Improved color detection (#1003)
* Improved color detection

* use pure python

---------

Co-authored-by: Alex Xu <alexkurosakimh3@gmail.com>
2025-06-30 17:18:04 -07:00
Alex Xu
c7ebb230c2 add L comment 2025-06-27 11:45:31 -07:00
Alex Xu
3e4b729a30 always convert to L
even if workImg.color = False, it could still have color pixels, which can cause problems with quantization
2025-06-27 07:19:22 -07:00
Adrian
16a1d9b45f Fix quantization for colored images (#991) 2025-06-26 07:36:22 -07:00
Adrian
217a18b7b5 Save images in GIF when output is set to MOBI and forcepng is used (#981)
* Save images in GIF when output is set to MOBI and forcepng option is used

* Save images in GIF when output is set to EPUB, kindle profile is used and forcepng option is set

* media-type="image/gif"

---------

Co-authored-by: Alex Xu <alexkurosakimh3@gmail.com>
2025-06-24 22:14:00 -07:00
Adrian
221f964f14 Improve code readability (#984) 2025-06-20 10:12:24 -07:00
Adrian
e9f0310b94 Fixes to grayscale pages in forcecolor mode (#978)
* Fix bit depth of non-color pages in forcecolor mode

* Optimization for JPEG non-color pages in forcecolor mode
2025-06-18 15:12:12 -07:00
Adrian
2fa90c9f59 Fix png bit depth (#976) 2025-06-18 15:11:59 -07:00
Alex Xu
f1db31205b split then rotate (#966) 2025-06-16 14:47:55 -07:00
Alex Xu
271200d29f fix scribe order 2025-06-16 10:50:52 -07:00
Alex Xu
a05111b64a Scribe 2480 support (#962)
* add imgfile2

* add 2480

* use older mozjpeg

* fix above below

* fix imgsize2

* fix newline

* rename targetPath

* fix cover.jpg

* fix opf

* fix above

* fix splitting
2025-06-13 16:45:27 -07:00
Alex Xu
eb0abb538c add tome text for splits (#963) 2025-06-13 12:22:07 -07:00
Alex Xu
4bb6ba55d3 cover has minimal processing and is shared across splits (#953)
* refactor cover handling

* skip cover processing

* rename cover to cover_path

* fix scribe mobi detection

* make things closer

* rename save to save_to_epub
2025-06-08 11:08:57 -07:00
Alex Xu
3ac5709e73 Add Kindle PW 7/10, Kindle 8/10 to PDOC list for easier covers (#955)
* add more pdoc

* update readme
2025-06-07 21:59:06 -07:00
Alex Xu
4712eac3c2 fix ebok thumbnail aspect ratio (#956) 2025-06-07 21:45:42 -07:00
Alex Xu
c3d2f89471 don't add white padding if forced white background checked 2025-05-14 09:18:33 -07:00
Alex Xu
b1c4cd36f1 don't add borders around small images 2025-05-14 09:18:33 -07:00
Alex Xu
36180f7904 Revert "fix Kindle Scribe panel view broken in 6.1.0 (#894)" (#903)
This reverts commit 1dd36e08eb.
2025-04-17 09:17:47 -07:00
Alex Xu
1c81a9d5b3 fix panel view order for no rotate (#897) 2025-04-15 15:38:03 -07:00
Alex Xu
1dd36e08eb fix Kindle Scribe panel view broken in 6.1.0 (#894) 2025-04-08 10:27:35 -07:00
Alex Xu
3e3710dd76 Add preserve margin % toggle (#886)
* preserve margin

* set ratio to 0.5

* add preserve margin GUI

* increase step size to 5

* remove clear

* fix save

* save preserveMarginBox

* math

* max 99
2025-04-03 10:11:14 -07:00
Alex Xu
4337d6c10d try to crop only main cover from wide cover scan (#875) 2025-03-21 10:17:23 -07:00
Alex Xu
9680ff24c2 split covers in half if too wide (#874) 2025-03-18 21:23:34 -07:00
Alex Xu
23099cee81 fix landscape alignment (#865) 2025-03-12 19:09:58 -07:00
Alex Xu
561951a349 restore imgMetadata dict (#858)
* Revert "memory optimization: store metadata in filenames, not a global dict (…"

This reverts commit 9a2a09eab9.

* only remove imgOld
2025-03-11 09:57:11 -07:00
Alex Xu
9a2a09eab9 memory optimization: store metadata in filenames, not a global dict (#853)
* remove options.imgMetadata and store metadata in filename

* make kcc much more memory efficient by removing imgMetadata and imgOld dicts
2025-03-09 16:52:07 -07:00
Alex Xu
9e204aad76 rename images before processing to fix splitting issues (#852)
* rename images before processing to fix splitting issues

* import pathlib

* 9999 page limit
2025-03-07 07:59:04 -08:00
Alex Xu
01625904d1 huge speed optimization on HDD by removing md5 (#845)
* Eliminate unnecessary use of MD5 checksum

md5checksum() computes the actual checksum of a specified file, which is appropriately expensive, but the code seemed to be using the checksum result as a key into the imgMetadata dictionary to avoid handling image files being renamed during processing steps. This seems like a very expensive way to handle the rename so instead, I now update the imgMetadata keys with the new filename in the one place that the rename happens, and avoid MD5 checksums entirely.

* merge conflicts

* Add missing handling for image path renames due to nested chapter folder name

* merge conflicts

* merge conflicts

* add perf_counters

* imgFileProcessing perf_counter

* use startswith and removeprefix

---------

Co-authored-by: utopiafallen <utopiafallen@gmail.com>
2025-03-04 11:28:23 -08:00
utopiafallen
62ffa2bc80 Improve processing performance by partially undoing "Refactored detection of corrupted files"
Commit f952634971 moved image corruption detection out from the ComicPage constructor and into a standalone detectCorruption() function. This led to a performance regression because now corruption detection happens in a single thread when it used to be distributed across worker threads, and because a source image is now loaded twice in memory: once during corruption detection and once when actually going to process the image.

Image file corruption detection is now back inside the ComicPage constructor and the extra load() has been removed because the convert() call will automatically invoke load() and most likely throw the same exceptions.
2025-02-28 19:49:13 -08:00
Alex Xu
3d4fae62d8 reduce rainbow checkbox (#824) 2025-02-09 19:10:56 -08:00
X5Games / Neyney10
2f703ef92c Inter-panel cropping method. (#810)
* Inter-panel cropping method.

* 1. Save interpanelcrop option.
2. Update readme with the the new interpanelcrop argument.
3. Add a tooltip to the inter-panel crop box.
2025-01-27 13:44:23 -08:00
Alex Xu
317fb33fd0 No Rotate option (#785)
* no rotate

* Revert "no rotate"

This reverts commit b6f1fe8882.

* implement norotate
2025-01-03 19:43:20 -08:00
Matthias Witte
4769f68265 Remarkable profiles (#781)
* Add profiles for remarkable 1, 2 and Paper Pro

* Add remarkable icons based on Other.png

* Mention remarkable profile in README.md
2024-12-13 14:08:08 -08:00
neyney10
4a661a1a17 [A new image cropping algorithm]
1. Replaced both crop margins and crop margins & page num with newer algorithm.
2. Crop max power level increased to 3.0
3. Adds NumPy as a new dependency.
2024-11-11 15:51:41 -08:00
Alex Xu
5168cd73c4 Make it easier to add new profiles (#764)
* refactor

* put pw12 under oasis profile

* remove kindle 12 tag

* separate ebok and pdoc

* put cs 12 on top
2024-11-04 20:24:12 -08:00
Alex Xu
8d204668a7 add kindle 12th gen, including colorsoft (#762)
* add kindle colorsoft

* fix typo
2024-10-23 21:17:22 -07:00
Dominik Gedon
44094bdb21 Add Kobo Libra/Clara colour (#703)
* fix: trailing whitespaces

* Add color toggle mode

* Add Kobo Libra Colour

Signed-off-by: Dominik Gedon <dominik@gedon.org>

* Add Kobo Clara Colour

Signed-off-by: Dominik Gedon <dominik@gedon.org>

* Address suggestions

* Address more suggestions

---------

Signed-off-by: Dominik Gedon <dominik@gedon.org>
2024-06-09 08:00:25 -07:00