View Full Version : Constrain Proportions of Cover Image?

12-30-2010, 10: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

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

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

<reference href="cover.jpg" type="cover" title="Cover" max-width="100%" max-height="100%"/>
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

12-31-2010, 10: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.

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

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

12-31-2010, 12:54 PM
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

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