ciromattia / kcc

KCC (a.k.a. Kindle Comic Converter) is a comic and manga converter for ebook readers.
ISC License
2.57k stars 206 forks source link

PDF cover got inserted into 2nd page instead of first page. #686

Open shihong5858 opened 4 months ago

shihong5858 commented 4 months ago

Describe the bug When converting a pdf manga into a CBZ file, the cover on the first page got inserted into 2nd page in CBZ file.

To Reproduce

  1. Using kcc.exe or command-line kcc-c2e.exe.
  2. Run this command or setting on the GUI: E:\kindle-bk\kcc-c2e.exe -p KoC -f CBZ -mus --cropping 1 --croppingpower 1 --gamma 1.35 E:\input\test2.pdf -o E:\output\test2.cbz
  3. The generated PDF got the cover inserted on the 2nd page.

Expected behavior The generated PDF got the cover inserted on the 1st page, like in the original PDF file.

Sample Files

CBZ PDF

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

axu2 commented 4 months ago

@shihong5858 Unfortunately, that is just the order of the images in the bytes of the pdf. You can verify it by running a

winget install --id=ArtifexSoftware.mutool  -e
mutool extract test.pdf 

image

Logic to follow the actual page order of the pdf could be possible, but considering how mutool doesn't account for it I'm not sure how to do it.

You could manually rename the first page, in pdfs I often find weird order issues with the first page.

shihong5858 commented 4 months ago

Thanks for the explanation.

The file was converted by Calibre command-line tool from a mobi file. The ordering was correct in the original mobi file. I guess I have to see if there's any configure I can tweak on the Calibre side then.

axu2 commented 4 months ago

@shihong5858 can't you use calibre to convert mobi to cbz/zip?

shihong5858 commented 4 months ago

@axu2 I've tried. Calibre cannot directly convert the file into cbz file (which is my target format), and I used to use zip as the intermediate format before passing to kcc. However when converting to zip files, I found some of the mobi files had put the cover page as a random page and they use metadata in .ncx/.opf to define the cover information. Therefore I tried to convert it into pdf (so it reads the metadata and put the cover as the first page) but found such issue.

axu2 commented 4 months ago

Ideally you would find a source that isn't mobi

shihong5858 commented 4 months ago

Yea... but the purpose of my script is to help ppl convert common format into kobo friendly format, so I cannot have a choice :P