View Full Version : Constrain Proportions of Cover Image?


markjoseph
12-30-2010, 09:59 PM
Hi All,

I'm using calibre and sigil, mostly, and have nice epub, lit, and mobi versions of my book. Yay! One problem. My cover expands to fit the window and looks awful. Is there any code I can plug in (in the .opf, possibly?) to get the image to constrain to its proportions?

I think I saw this somewhere and can't remember what i did. Thank you. markjoseph www.thewordgang.com

Jellby
12-31-2010, 03:58 AM
Do not use "width: 100%; height: 100%", use instead: "max-width: 100%; max-height: 100%"

markjoseph
12-31-2010, 08:08 AM
Thanks Jelby, I must be doing something wrong. Tried it in both opf files a la:

<guide>
<reference href="cover.jpg" type="cover" title="Cover" max-width="100%" max-height="100%"/>
</guide>
</package>
and it didn't constrain the cover image. There's a "metadata.opf" as well as a "Word Gang, The - Mark McKenna.opf" file. I tried it in both of them and monkeyed around with the "" and :'s. Now what? markjoseph

Jellby
12-31-2010, 09:00 AM
You cannot use CSS code in the OPF.

If "cover.jpg" is used in some XHTML file, in a <img> element, then there's where you have to add/modify the CSS (have a look at some tutorial on HTML/CSS to know what you are doing).

If "cover.jpg" is only referred in that guide element, then I don't think there's nothing you can do, and the reader is just buggy.

theducks
12-31-2010, 10:37 AM
Are you supposed to quot the 100% in a Guide?
You don't in a style sheet

kovidgoyal
12-31-2010, 11:11 AM
Under epub output in the calibre conversion settings check preserve aspect ratio

markjoseph
12-31-2010, 11:54 AM
Thanks Kovid, I knew i saw it somewhere. (Add another point to your karma.) I'll add some $$ points as soon as I receive some of the New Year's cheer I've been expecting. To fix the cover I'm going to try to go epub to epub. I think I did this before and it worked. Is that a good practice? markjoseph

kovidgoyal
12-31-2010, 12:54 PM
that is the most reliable way to fix epub covers.