Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PackageReader to pick up cover images as generated on Adobe Indesign #32

Conversation

arctouch-camilovilela
Copy link

Adobe InDesign generates cover images on EPUBs using "name" and "content" attributes on a 3.0 EPUB.

@vers-one
Copy link
Owner

vers-one commented Jul 8, 2020

Hmm, that's interesting. name and content attributes are not present in the EPUB 3 specification but they are allowed in EPUB 2 [1, 2] and handled correctly by EpubReader in that case.

I will try to get Adobe Indesign and see what's going on there.

Thanks for the notice!

@vers-one vers-one self-assigned this Feb 23, 2022
@vers-one
Copy link
Owner

I will close and reopen this pull request to restart the build check.

@vers-one vers-one closed this Feb 23, 2022
@vers-one vers-one reopened this Feb 23, 2022
Copy link
Owner

@vers-one vers-one left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for a delayed response (almost two years! 🙂)

I finally got access to Adobe Indesign and can confirm that it does indeed produce EPUB 2 <meta name="..." content="..." /> tags in EPUB 3 files. Surprisingly, it is allowed by EPUB 3.2 specification. From https://www.w3.org/publishing/epub32/epub-packages.html#sec-opf2-meta:

The meta element [OPF2] is a legacy feature that previously provided a means of including generic metadata. It is replaced in EPUB 3 by the updated meta element, which uses different attributes and requires text content.

And the definition for legacy:

Authors MAY include the legacy feature for compatibility purposes.
Reading Systems MUST NOT support the legacy feature in content that conforms to this version of EPUB.

It seems to me that there is no harm in supporting both types of meta elements in EpubReader. However, instead of changing the ReadMetadataMetaVersion3 method I would suggest replacing both ReadMetadataMetaVersion2 and ReadMetadataMetaVersion3 with a single ReadMetadataMeta method that would try to read all available EPUB 2 and EPUB 3 attributes and would give a preference for the content attribute over the element value if both are present.

As for the cover images, I now realize that EpubReader doesn't fully support EPUB 3 covers. According to EPUB 3.2 specification, the cover could be provided via <item properties="cover-image" /> manifest element which is parsed correctly by EpubReader but not used in the BookCoverReader class. There has been a couple attempts in the past to add some heuristics in the cover reading algorithm [1, 2] but they are not standard-compliant and don't always work. (I really should have been more thorough in reviewing those pull requests.) We can safely replace the heuristic with a proper implementation.

Let me know if you want me to make those changes or if you prefer to make them yourself in this pull request.

@vers-one vers-one mentioned this pull request Jun 26, 2022
2 tasks
@vers-one
Copy link
Owner

Implemented in PR #49.
@arctouch-camilovilela, thank you for suggestion!

@vers-one vers-one closed this Jun 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants