benchen71 / epub-metadata-editor

Edit the metadata of EPUB files
194 stars 11 forks source link

Cover detect for EPUB 3 #41

Closed BeckyDTP closed 5 years ago

BeckyDTP commented 5 years ago

Proper cover image is not detected in EPUB 3 files.

Guide element is deprecated: http://www.idpf.org/epub/301/spec/epub-publications.html#sec-guide-elem

Important is cover-image in manifest section opf file: http://www.idpf.org/epub/301/spec/epub-publications.html#sec-item-property-values

Sample file: Sample_file_epub.zip

Please improve detect cover in EPUB 3 files, especially in the command line: -extract cover

benchen71 commented 5 years ago

I'll take a look at this over the weekend.

benchen71 commented 5 years ago

Had a chance to look at this tonight and made the change: try 1.6.12 and it will pick up cover information from the . The command-line program has also been updated.

BeckyDTP commented 5 years ago

1.6.12 is great for EPUB3. Thank you!

I would be happy if the detection of the cover would also check existence the cover element in the metadata (EPUB2/EPUB3): <meta name="cover" content="id_of_cover_image" />

If guide section is without "cover" element, "cover" in meta is an important place that should be checked when detecting the cover.

benchen71 commented 5 years ago

The program was looking for "likely" cover ids. But I have now added some code as a last ditch attempt (which should probably be a "first ditch" attempt now that I think about it!) which does what you have requested: it searches for "<meta name="cover"", retrieves the id, and then searches for that id in the manifest.

BeckyDTP commented 5 years ago

Yes, 1.613 is better, thank you!

I will ask for one more thing – reverse order in meta (name="cover" after content): <meta content="id_of_cover_image" name="cover" />

benchen71 commented 5 years ago

Done. That was surprisingly a lot harder to do. I've only lightly tested this so if you encounter any problems, please let me know.

BeckyDTP commented 5 years ago

It's amazing how much the program has been perfected in one day. 👍

I have the impression that the version 1.6.14 has improved detects covers only in the GUI version (command-line -extract cover result: ERROR).

benchen71 commented 5 years ago

Can you attach an EPUB that generates an error? I'll look into it...

BeckyDTP commented 5 years ago

Sure.

Additional file as sample divergence/mismatch data for cover in opf file.

This file has other cover declared in guide section and other in cover meta. In such (very rare) cases, the program could inform about this fact. Why? Well, kindlegen uses data from the meta (when in guide section is xhtml file, not image), so the mobi file generated on the basis of such a "difficult case" will have a bad cover. I bought a file with this error in an ebook bookstore this year, so such a mistake may occur in the wild.

test_files_for_command_line.zip

benchen71 commented 5 years ago

Turns out I neglected to include the updated version of the Console! So now I've updated the version numbers on both to 1.6.15. I'm not going to be able to handle divergence files. That's something that will have to be handled by manually editing the opf file.

BeckyDTP commented 5 years ago

OK. Thank you. LastTestCommandLine.zip

BeckyDTP commented 5 years ago

Just in case, two more files for testing (plus the one from the previous message).

Sample file from bookstore Results: GUI: OK Command line: ERROR

Free ebook (Download ePub) Results: GUI: ERROR Command line: ERROR

benchen71 commented 5 years ago

Thanks for those. I've found what was causing the problem in the Console version. And I've now changed the cover processing order so that it the program starts by looking for <meta ... name="cover". These changes probably warrant a bigger update, so 1.7.0 will come out tomorrow, if I have time to do some further testing.