Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 01-25-2015, 09:24 AM   #16
RS21
Junior Member
RS21 began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Jan 2015
Device: Sony PRS-650
Alternative to cover svg wrapper

I used this solution to make my cover image fit in the reader's screen.
Quote:
Originally Posted by pdurrant View Post
[B]
It is possible to get an image to properly resize to fill the page using an svg wrapper.

<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%" viewBox="0 0 573 800" preserveAspectRatio="xMidYMid meet">
<image width="573" height="800" xlink:href="../images/img0032.png" />
</svg>

which I use for the cover image.
However, I noticed that the eBook took about 40 seconds to load for the first time. Removing the cover image made it load much faster, about 5 seconds, identifying the cover image as the culprit.

So, I tried a more straight-forward solution. Mark-up:
Code:
<body>
  <div>
    <img id="cover" src="../Images/cover.jpg" />
  </div>
</body>
and style:
Code:
img#cover 
{
  max-width: 100%;
  max-height: 100%;
  display: block;
  margin-left: auto;
  margin-right: auto;
}
This will maintain aspect ratio, and will horizontally center the image, if the screen is wider than the image. Vertical alignment will be top.
RS21 is offline   Reply With Quote
Old 01-25-2015, 10:05 AM   #17
pdurrant
The Grand Mouse 高貴的老鼠
pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.
 
pdurrant's Avatar
 
Posts: 71,506
Karma: 306214458
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
Quote:
Originally Posted by RS21 View Post
I used this solution to make my cover image fit in the reader's screen.


However, I noticed that the eBook took about 40 seconds to load for the first time. Removing the cover image made it load much faster, about 5 seconds, identifying the cover image as the culprit.

So, I tried a more straight-forward solution. Mark-up:
Code:
<body>
  <div>
    <img id="cover" src="../Images/cover.jpg" />
  </div>
</body>
and style:
Code:
img#cover 
{
  max-width: 100%;
  max-height: 100%;
  display: block;
  margin-left: auto;
  margin-right: auto;
}
This will maintain aspect ratio, and will horizontally center the image, if the screen is wider than the image. Vertical alignment will be top.
I'm surprised that you see this preserving the aspect ratio. What are you viewing it on?
pdurrant is offline   Reply With Quote
Advert
Old 01-25-2015, 10:40 AM   #18
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,516
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by RS21 View Post
Code:
img#cover 
{
  max-width: 100%;
  max-height: 100%;
  display: block;
  margin-left: auto;
  margin-right: auto;
}
This will maintain aspect ratio,
No guarantee, as far as I know. An oversized image could be downscaled to 100% width and 100% height, which does not preserve aspect ratio.

Quote:
and will horizontally center the image
only if the reader does not ignore auto margins, and it is allowed to.

The problem of that approach (and actually the same more or less applies to the standard SVG wrapper) is that there is no way to access screen height. "height: 100%" might give you a full height, or maybe not.
Jellby is offline   Reply With Quote
Old 01-27-2015, 11:11 PM   #19
dgatwood
Curmudgeon
dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.
 
dgatwood's Avatar
 
Posts: 629
Karma: 1623086
Join Date: Jan 2012
Device: iPad, iPhone, Nook Simple Touch
Quote:
Originally Posted by Jellby View Post
No guarantee, as far as I know. An oversized image could be downscaled to 100% width and 100% height, which does not preserve aspect ratio.



only if the reader does not ignore auto margins, and it is allowed to.

The problem of that approach (and actually the same more or less applies to the standard SVG wrapper) is that there is no way to access screen height. "height: 100%" might give you a full height, or maybe not.
A height of 100% will give you the full height as long as there's no padding or margins anywhere in any of your enclosing elements, and as long as they're all set to a height of 100%. This approach, of course, requires each SVG image to be in a separate HTML file.

It's too bad EPUB 3 didn't mandate support for CSS 3, because then you'd have vh/vw/vmin/vmax.... *sigh*
dgatwood is offline   Reply With Quote
Old 01-28-2015, 05:51 AM   #20
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,516
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by dgatwood View Post
A height of 100% will give you the full height as long as there's no padding or margins anywhere in any of your enclosing elements, and as long as they're all set to a height of 100%.
And as long as the renderer interprets it that way.
Jellby is offline   Reply With Quote
Advert
Old 01-28-2015, 07:49 AM   #21
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
Some readers will actually give issues if you use height: 100%.
Toxaris is offline   Reply With Quote
Old 01-29-2015, 02:56 AM   #22
dgatwood
Curmudgeon
dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.
 
dgatwood's Avatar
 
Posts: 629
Karma: 1623086
Join Date: Jan 2012
Device: iPad, iPhone, Nook Simple Touch
Quote:
Originally Posted by Jellby View Post
And as long as the renderer interprets it that way.
There's no other valid way to interpret it. The CSS spec is pretty explicit about what 100% means. It means 100% of the enclosing container's size, and 100% on the outermost tag (HTML) means fill the entire viewport. The only problems you might run into involve padding and margins (because it is 100% of the total box size, not the interior dimensions of the box).

In theory (I haven't tried this), you could also set the position to absolute and set left, right, top, and bottom to 0, and you should get the same results. Or you could set width and height to auto instead of 100%. Just as long as you do it on all elements (including html), it should work, but again, I haven't tried it.


Quote:
Originally Posted by Toxaris View Post
Some readers will actually give issues if you use height: 100%.
Really? Experimentally, it works fine for me in ADE, RMSDK (e.g. Nook), iBooks, Kindle, and other WebKit-based readers. That should cover everything but a handful of obscure third-party reader apps (and experimentally, it works on nearly all of those, at least on iOS, and I filed bugs against the one that misbehaved with zero-length margins/padding, and I'm pretty sure they fixed it).

What readers did you have problems with height: 100% in, and under what circumstances?
dgatwood is offline   Reply With Quote
Old 01-29-2015, 03:37 AM   #23
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
Quote:
Originally Posted by dgatwood View Post
Really? Experimentally, it works fine for me in ADE, RMSDK (e.g. Nook), iBooks, Kindle, and other WebKit-based readers. That should cover everything but a handful of obscure third-party reader apps (and experimentally, it works on nearly all of those, at least on iOS, and I filed bugs against the one that misbehaved with zero-length margins/padding, and I'm pretty sure they fixed it).

What readers did you have problems with height: 100% in, and under what circumstances?
Really. I would not name the reader obscure though...
In certain cases Sony readers will have an issue with this and will not allow you to advance to the next page. You have to actually have to go to the next page by entering the page number.
Toxaris is offline   Reply With Quote
Old 01-29-2015, 05:09 AM   #24
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,516
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by dgatwood View Post
There's no other valid way to interpret it. The CSS spec is pretty explicit about what 100% means. It means 100% of the enclosing container's size, and 100% on the outermost tag (HTML) means fill the entire viewport.
Unfortunately, that's in CSS 2.1, CSS 2.0 is not so clear (it makes to mention of the initial containing block for the root element), and ePub 2.0.1 requires CSS 2.0, not 2.1.

Of course, with ePub 3 and CSS 3, the situation is different, and then you can blame the renderers for not following the specs if they don't. But I still live in an ePub 2 world
Jellby is offline   Reply With Quote
Old 01-30-2015, 01:01 AM   #25
dgatwood
Curmudgeon
dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.
 
dgatwood's Avatar
 
Posts: 629
Karma: 1623086
Join Date: Jan 2012
Device: iPad, iPhone, Nook Simple Touch
Quote:
Originally Posted by Jellby View Post
Unfortunately, that's in CSS 2.1, CSS 2.0 is not so clear (it makes to mention of the initial containing block for the root element), and ePub 2.0.1 requires CSS 2.0, not 2.1.
Wow, you're right. I was confused because the CSS 2.1 spec is incorrectly published as "CSS2" on the W3C's website. Blecch.

Well, actually, it does mention it. It just says that it is defined by the user agent.... Such text, in specifications, is almost invariably a mistake, in my experience.
dgatwood is offline   Reply With Quote
Old 01-30-2015, 01:17 PM   #26
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,516
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
To be honest, regardless of what the specs says, it all boils down to what the readers implement, and we may be lucky there.
Jellby is offline   Reply With Quote
Old 01-30-2015, 04:30 PM   #27
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 73,974
Karma: 128903378
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by Toxaris View Post
Really. I would not name the reader obscure though...
In certain cases Sony readers will have an issue with this and will not allow you to advance to the next page. You have to actually have to go to the next page by entering the page number.
I've never seen this with a 505, 650, & T1. So which Sony Readers have this problem?
JSWolf is offline   Reply With Quote
Old 01-30-2015, 05:02 PM   #28
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
The T1 for sure. I reported it quite some time ago in the Sony subforum. It was a combination of height and another attribute, I believe line-height.

found it: https://www.mobileread.com/forums/sho...9&postcount=16

Last edited by Toxaris; 01-30-2015 at 05:05 PM.
Toxaris is offline   Reply With Quote
Old 05-08-2015, 10:21 AM   #29
xmlgirl
Enthusiast
xmlgirl ought to be getting tired of karma fortunes by now.xmlgirl ought to be getting tired of karma fortunes by now.xmlgirl ought to be getting tired of karma fortunes by now.xmlgirl ought to be getting tired of karma fortunes by now.xmlgirl ought to be getting tired of karma fortunes by now.xmlgirl ought to be getting tired of karma fortunes by now.xmlgirl ought to be getting tired of karma fortunes by now.xmlgirl ought to be getting tired of karma fortunes by now.xmlgirl ought to be getting tired of karma fortunes by now.xmlgirl ought to be getting tired of karma fortunes by now.xmlgirl ought to be getting tired of karma fortunes by now.
 
Posts: 29
Karma: 496864
Join Date: Mar 2012
Location: Virginia
Device: none
This is an older thread, but wondering if these are still the best ways out there to size images? Nothing better has come along?
xmlgirl is offline   Reply With Quote
Old 09-25-2015, 07:25 PM   #30
sjkramer
Connoisseur
sjkramer ought to be getting tired of karma fortunes by now.sjkramer ought to be getting tired of karma fortunes by now.sjkramer ought to be getting tired of karma fortunes by now.sjkramer ought to be getting tired of karma fortunes by now.sjkramer ought to be getting tired of karma fortunes by now.sjkramer ought to be getting tired of karma fortunes by now.sjkramer ought to be getting tired of karma fortunes by now.sjkramer ought to be getting tired of karma fortunes by now.sjkramer ought to be getting tired of karma fortunes by now.sjkramer ought to be getting tired of karma fortunes by now.sjkramer ought to be getting tired of karma fortunes by now.
 
Posts: 68
Karma: 526028
Join Date: Nov 2009
Location: New York, NY
Device: iphone
Seconded

Quote:
Originally Posted by xmlgirl View Post
This is an older thread, but wondering if these are still the best ways out there to size images? Nothing better has come along?
Just seconding this query.
sjkramer is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding epubs to iTunes with cover images sartori ePub 31 09-30-2010 12:39 PM
Adding Images To Ebook gtshadow Calibre 3 09-29-2010 11:23 AM
EPUB tips from Adobe AprilHare Workshop 1 12-20-2009 04:59 PM
Tips on creating EPUB Student1 ePub 3 03-22-2009 12:41 AM


All times are GMT -4. The time now is 08:03 AM.


MobileRead.com is a privately owned, operated and funded community.