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

Using \coverimage with an SVG results in bizarrely cropped cover image #72

Open
DavidGriffith opened this issue Jun 27, 2020 · 4 comments

Comments

@DavidGriffith
Copy link

I can't put a finger on exactly what causes this, but now that I found it, I can't seem to create a demo EPUB that results in a correctly-rendered cover. The problem is that if I do \coverimage{cover.svg}, an epub reader will render the cover strangely cropped. Sometimes it was a strip off the bottom. More recently three quarters of the SVG is removed. If I do \coverimage{cover.png}, the image appears as it should.

To recreate a misbehaving EPUB, do tex4ebook -xs -f epub3 -c badcover.cfg badcover.tex:

% badcover.tex
\documentclass[12pt]{book}
\usepackage{graphicx}
\usepackage{svg}
\usepackage{lipsum}

\title{Bad Cover}
\author{David Griffith}

\begin{document}
\coverimage{badcover.svg}
\maketitle
\tableofcontents

\chapter{Hello}
\lipsum[1]
\chapter{Goodbye}
\lipsum[1]
\chapter{Hello Again}
\lipsum[1]
\chapter{Whee!}
\lipsum[1]
\end{document}
% badcover.cfg
\Preamble{xhtml}
\Configure{UniqueIdentifier}{661.org}
\DeclareGraphicsExtensions{.svg,.png,.jpg,.gif}
\renewcommand\includesvg[2][]{\includegraphics{#2}}
\Configure{CoverMimeType}{image/svg+xml}
\begin{document}
\EndPreamble

Here's how Calibre renders the bad graphic:
Screenshot at 2020-06-27 00-29-40

Here's the SVG:
badcover.zip

Here's the PNG as created with convert badcover.svg badcover.png:
badcover

@michal-h21
Copy link
Owner

This is strange, it works correctly on my machine. This is my <img> element in badcover.html:

  <img src="badcover.svg" alt="PIC"  />

Maybe you have some additional attributes here?

@DavidGriffith
Copy link
Author

<body 
>
   <div class="cover-image"> 
 <img 
src="badcover.svg" alt="PIC"  
 /></div>

@michal-h21
Copy link
Owner

So this is the same. Maybe it is a bug in (or feature?) in Calibre? It seems that it crops the image only in the library view, it displays it correctly when I open the book in ebook-viewer.

@DavidGriffith
Copy link
Author

DavidGriffith commented Jun 30, 2020

Alkdiko on Android does this too.

Here's the bad epub so we can see if this renders poorly for you.
badcover-epub.zip

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

No branches or pull requests

2 participants