GithubHelp home page GithubHelp logo

Comments (7)

vers-one avatar vers-one commented on July 17, 2024

That's interesting. Can you upload your epub file somewhere so I can take a look?

from epubreader.

ilia-valchenko avatar ilia-valchenko commented on July 17, 2024

@versfx Yes, of course. There are few books which I used. Unfortunately you should download it from google drive because github doesn't support epub extension in attachment. https://drive.google.com/drive/folders/0BwwwPXS7GsatY25xWVRxUmh6TWc?usp=sharing

from epubreader.

ilia-valchenko avatar ilia-valchenko commented on July 17, 2024

@versfx I found one interesting fact. I looked into few epub archives and found that a book cover image might situated into a different folder (for example OPS\images, OEBPS\images). Some archive doesn't have folder which contains any other images.

from epubreader.

vers-one avatar vers-one commented on July 17, 2024

EPUB specification does not define a way to describe covers, but the usual practice is to set it using <meta name="cover" /> tag in the OPF file (as a reference to the cover image file). In addition to that some books also provide an alternative XHTML version of the cover using <item id="cover" media-type="application/xhtml+xml" /> tag (in the manifest section) and/or using <reference type="cover" /> tag (in the guide section), however I haven't seen a book with XHTML cover which didn't have an image version of the cover.

In your case:

  • Carroll_Lewis_-_Alice_Adventures_in_Wonderland.epub: has XHTML cover in the reference tag, but there is no image version of the cover specified;
  • Chehov_Anton_-_Rasskazy_1887.epub: also XHTML cover in the reference tag, no image version;
  • Conan_Doyle_Arthur_-_The_Lost_World.epub: has image version specified as <meta content="item6" name="cover" />, but there is no content element with ID = "item6" in the manifest section below;
  • the-doomed-city.epub and zhuk-v-myraveinike.epub: no specified covers.

Pocket Book reader probably takes XHTML versions or renders the first page of the book as a cover.

If you want to get an XHTML version of the cover from the guide section (which again is very unusual for the most of epub files), you can do it like this:

EpubGuideReference coverPageReference = epubBook.Schema.Package.Guide.FirstOrDefault(reference => String.Compare(reference.Type, "cover", StringComparison.OrdinalIgnoreCase) == 0);
if (coverPageReference != null)
{
    EpubTextContentFile coverPage;
    if (epubBook.Content.Html.TryGetValue(coverPageReference.Href, out coverPage))
    {
        // coverPage.Content has XHTML version of the cover page
    }
}

from epubreader.

ilia-valchenko avatar ilia-valchenko commented on July 17, 2024

@versfx What do you think it's a good idea to search a book's cover across the archive folder and then store it in a database (as array of bytes for example)? Unfortunately a lot of books will have incorrect a book's metadata. I think that change a book's metadata it's not a good idea. I develop the ePUB reader application based on Xamarin.Forms. A default user can't change metadata by itself. Do you have any other elegant ideas how to get a book's cover image. I know that I can display it by using cover.html, but I'm looking for a approach to display a book's preview at my home page. Also I want to say thanks for you informative answers.

from epubreader.

vers-one avatar vers-one commented on July 17, 2024

The problem is that you cannot distinguish cover image from other images in the book unless it is explicitly marked as a cover. Of course you can apply some heuristics by looking for an image that has "cover" in its name but this is not very robust solution. Another approach would be to show all the images (epubBook.Content.Images) to the users and ask them to choose the cover.

from epubreader.

vers-one avatar vers-one commented on July 17, 2024

Please let me know if you have any other questions or comments.

from epubreader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.