Fall back to a default resolution when the target profile has none - #1400
Open
NilsLeo wants to merge 2 commits into
Open
Fall back to a default resolution when the target profile has none#1400NilsLeo wants to merge 2 commits into
NilsLeo wants to merge 2 commits into
Conversation
Selecting the generic 'Other'/'OTHER' device (profile resolution (0,0)) without supplying custom width/height propagated a (0,0) target resolution into PIL resize/thumbnail, crashing every such conversion with a ZeroDivisionError. Fall back to a sane default e-reader resolution (1264x1680) when the resolved profile has a zero dimension, and defensively skip any genuinely zero-dimension source image during validation.
Modern Pillow raises UnidentifiedImageError when opening a zero-dimension image, so `0 in img.size` is never reached and the check was effectively dead code (the corrupt-image path already handles that file). Keep only the (0, 0) target-resolution fallback, which is the reachable fix. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
|
this works with any file but ive added one just in case |
Contributor
Author
|
Hey! Would it be possible to grant me Maintainer access to the repository? I don't need to be able to push directly to |
Collaborator
|
I don't think that's needed, I personally don't do any work on ciromattia/kcc, I do everything in my fork and PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Selecting the generic 'Other'/'OTHER' device (profile resolution
(0, 0)) without supplying custom width/height propagates a(0, 0)target into PIL resize/thumbnail, crashing every such conversion with aZeroDivisionError.This falls back to a sane default e-reader resolution (1264×1680) when the resolved profile has a zero dimension, so the generic profile no longer hard-crashes.
How to reproduce / test
Any convertible comic reproduces this — the crash is about the profile, not the file. You just need an archive that extracts cleanly and is converted with
-p OTHER(no custom-u/width/height, so the target resolution stays(0, 0)).Download: https://drive.google.com/file/d/1z7SlgQZxPTADimAOhDKxhC41lVmQOMM7/view?usp=drive_link
Save it next to where you run the commands (referred to below as
1400.cbz). It is a plain flat CBZ of valid pages; the only thing that matters is the-p OTHERprofile.The easiest way to A/B test any KCC branch without a local setup is
kcc-run, which clones a givenowner/repo:refinto a throwaway container at runtime:1. Reproduce the crash on upstream master (
-p OTHER, no custom size):→ aborts with
ZeroDivisionError: division by zeroinPIL/Image.pythumbnail(target resolution(0, 0)).2. Same file on this branch — falls back and converts:
→ logs
WARNING: profile "OTHER" has no resolution; falling back to 1264x1680, then writes a validout/1400.epub.Control — a real profile already works on master, confirming it is the profile and not the file:
(Or clone this branch and run
python kcc-c2e.py -p OTHER -f EPUB -o out 1400.cbzdirectly.)