12-03-2015, 02:33 PM | #1 |
Read, don't parrot.
Posts: 224
Karma: 110242
Join Date: Apr 2011
Device: Kindle Fire, Kobo Touch, Aldiko for Android
|
Images not displaying properly in iBooks
I'm trying to help an elderly friend who has written a book for her kids and wants to be able to give it to them as an ePub. Problem is, she has an iPad and uses iBooks while her children use a mix of iPads (various generations) and Android tablets, and has no idea which of the myriad of ePub apps they might be using.
Apple dictate that all images must be placed in containers (to work around the bug they refuse to fix) and they ask for images to be coded as: Code:
HTML: <div class="image-container"> <img src="images/bears.jpg" alt="three bears peer at goldie locks"/> </div> CSS: img {height: 100%;} .image-container {height: 100%;} I also added a second image container for horizontal images: Code:
.image-container2 {width: 100%;} If one changes the img value to 100% width, then horizontal images work but not vertical. How, then, does one code as Apple dictates but have both vertical and horizontal images in your ebook? I tried to fix the problem by removing the img value from the CSS and creating classes I could add to divisions and to the img tag: Code:
CSS: .imageV {height: 50%; text-align:center; margin-bottom: 1em;} .imageH {width: 100%; text-align:center; margin-bottom: 1em;} .imageC {height: 100%; text-align:center;} .vertical {height:100%;} .horizon {width:100%;} HTML: <div class="imageV"> <img class="vertical" alt="child" src="../Images/child.jpg"/> </div> <div class="imageH"> <img class="horizon" alt="mother" src="../Images/mother.jpg"/> </div> Help! |
12-03-2015, 03:02 PM | #2 |
Wizard
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
If the images are supposed to fill the complete page as much as possible, but not be distorted, I would strongly recommend a svg container. This is also much used for covers and does work on iBooks as far as I know. You can actually do this quite easily with Sigil and the svgwrapper plugin.
|
Advert | |
|
12-03-2015, 04:01 PM | #3 |
Read, don't parrot.
Posts: 224
Karma: 110242
Join Date: Apr 2011
Device: Kindle Fire, Kobo Touch, Aldiko for Android
|
The images are not supposed to fill the page; the vertical ones are 50%, the horizontal ones ends up about the same height-wise simply because they are horizontal. This is what she wants (the images are at the start of chapters). Only the cover is 100% height.
Apple iBooks doesn't read SVG wrappers, at least as far as I know. In the past, images in SVG wrappers were still often split over screens, at least when I tested them back then. The SVG wrapper worked beautifully in most ePubs, but then the new Kobo Arc, when I tested it in late 2014, ignored the SVG wrapper. (Kobo's bithub page warns that SVG images may not display correctly across devices). And the latest Apple Asset Guide states: "To ensure proper viewing of images in content, use the HTML img tag instead of wrapping images in svg:img." So I'm at a loss as to how to code images that will work in both Apple iBooks and general ePub apps. |
12-03-2015, 04:33 PM | #4 |
Wizard
Posts: 1,602
Karma: 7999999
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
|
12-03-2015, 07:49 PM | #5 |
Read, don't parrot.
Posts: 224
Karma: 110242
Join Date: Apr 2011
Device: Kindle Fire, Kobo Touch, Aldiko for Android
|
Alas, that's worse: in ADE, the image not only balloons to full screen but it overlaps text. I recall Kobo not reading "auto" as well when I tried it last year. Earlier today I also tried
Code:
img { height: 100%; width: auto; } I just spoke with my friend. She agrees this is an exercise in futility and I'm going to make her a regular ePub with the height and width set in the image tag as has worked historically, and which pretty much every other ePub reader is programmed to recognize, and her family can download another (better) ePub reader to their iPads. Thanks for your suggestions, though. Truly appreciated. (And the fact that there haven't been more suggestions on this forum, where I usually find solutions within a few hours, tells me that maybe there isn't a solution to this particular problem. Apple sucks.) |
Advert | |
|
12-04-2015, 11:54 PM | #6 | ||
Curmudgeon
Posts: 629
Karma: 1623086
Join Date: Jan 2012
Device: iPad, iPhone, Nook Simple Touch
|
Quote:
Code:
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg" xmlns:epub="http://www.idpf.org/2007/ops"> <head> <title>Cover</title> <link rel="stylesheet" type="text/css" href="nookstyles.css" /> <link rel="stylesheet" type="text/css" href="nookstyles2.css" /> <style type="text/css"> html,body { height: 100% !important; min-height: 100% !important; width: 100% !important; margin: 0 !important; border-width: 0 !important; padding: 0 !important; } </style> </head> <body style="oeb-column-number: 1; background-color: #000000;" > <div class="coverpage"> <svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="100%" height="100%" id="svg2" xml:space="preserve" viewBox="0 0 2040 2640" preserveAspectRatio="xMidYMid meet"> <image xlink:href="frontcover.jpg" height="2640" width="2040"> <desc>Patriots: A Patriots Christmas</desc> </image> </svg> </div> </body> </html> Code:
div.coverpage { height: 100%; margin: 0; padding: 0; border-width: 0; } Quote:
I'm guessing this is a case of miscommunication between an engineer and a tech writer who didn't fully grasp the intricacies of XHTML namespaces and other minutiae. Heck, I barely grasp the intricacies of it, and I've been doing this for longer than I care to admit. Last edited by dgatwood; 12-05-2015 at 12:06 AM. |
||
12-05-2015, 01:43 PM | #7 |
Read, don't parrot.
Posts: 224
Karma: 110242
Join Date: Apr 2011
Device: Kindle Fire, Kobo Touch, Aldiko for Android
|
Years ago, I built a book for a friend using what was then the standard SVG wrapper, that looked, for example, like this:
Code:
<svg xmlns="http://www.w3.org/2000/svg" style="max-width:800px; max-height:1200px" height="90%" preserveAspectRatio="xMidYMid meet" width="90%" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" viewBox="0 0 800 1200" > <image alt="" height="1200" width="800" xlink:href="../Images/cover.jpg"></image> </svg> So I'm stumped. |
12-05-2015, 09:03 PM | #8 |
Curmudgeon
Posts: 629
Karma: 1623086
Join Date: Jan 2012
Device: iPad, iPhone, Nook Simple Touch
|
There are several reasons your approach didn't work:
1. The screen isn't necessarily 800x1200, so that won't necessarily fill a page. 2. There's no page-break-before to force it to begin at the start of a page. 3. Even if you included page-break-before, the height:90% would still not be 90% the height of the viewport, but rather 90% the height of the enclosing container (the body element), I think. The SVG wrapper approach requires the image to be by itself in an HTML file, with nothing else in that file. That way, the 100% width and height on the top-level element (html) are relative to the viewport height, the 100% dimensions on the next element (body) are relative to the html element (which is equal to the viewport size), etc. |
12-06-2015, 12:15 AM | #9 |
Read, don't parrot.
Posts: 224
Karma: 110242
Join Date: Apr 2011
Device: Kindle Fire, Kobo Touch, Aldiko for Android
|
The SVG wrapper I included was, as I said, from some years ago. And yes, 800x1200 is no longer the norm. The code was just by way of example of the SVG wrapper that Apple did not and, as far as I know, continues not to, read. Which is why I did not use it with this latest project.
SVG-wrapped images have never required the image to be in its own HTML file. I produced my image-heavy manuals between 2009 and 2012 using the SVG wrapper and the images were interspersed throughout the text. There is no need, or indeed desire, for images to have a page break before them in many cases. The "height=90%" attribute caused the image to display at 90% of the screen. However, if 90% of the screen was larger than, in the above example, 1200 pixels, the SVG wrapper's max height and width attributes prevented small images from being resized in larger screens. Instead of displaying at 90%, the image would display at 1200 pixels, whatever percentage of the screen that was. When the first-generation larger screens appeared but many people did not have images of sufficient size to accommodate these new larger screens, the SVG wrapper prevented unsightly uprezzing. The SVG wrapper also prevented image distortion on the new rotating screens, and thus became a staple of ebook coding. However, the programming of latest-generation devices with regard to image handling has become in a sense the new DRM -- it's a way to force publishers to produce retailer-specific files and therefore force consumers into brand "loyalty." Which is why we are stuck here with this stupid Apple problem and so far no solution. Last edited by eggheadbooks1; 12-06-2015 at 12:18 AM. |
12-07-2015, 07:13 PM | #10 | |
Bookmaker & Cat Slave
Posts: 11,482
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
Quote:
If memory serves, there were issues with the first-gen iPad, too, surrounding images. I think I'm correct when I say that we worked around it by embedding the images in not 1, but 2, divs. The first one set the h/w of the area, the second was to set the size of the image itself, and THEN we put the image inside the nested div, at 100% max-height/width. (So, 100% div, with an X% div inside, say, 50% in this instance, and then 100% max-width for the image, inside that 50% container div. See what I mean?) Have you tried either doing that--two divs and a nested image tag--or using max-height/width? And SVG may well be your answer, but I wanted to ask about the nested divs and the max-XXX factors. Hitch |
|
12-07-2015, 10:25 PM | #11 | |
Read, don't parrot.
Posts: 224
Karma: 110242
Join Date: Apr 2011
Device: Kindle Fire, Kobo Touch, Aldiko for Android
|
Quote:
I hadn't tried the double nest approach. If I understand correctly, you are creating another level of div so as to avoid the need to put a class in the img tag. Correct? I loved the SVG wrapper but it doesn't work in iBooks, at least not in my experience. Books using the SVG wrapper still had images sometimes split over screens in iBooks. And the latest-generation Kobos also ignore it. Last year, when I published the latest edition of my self-pubbing book that has a lot of images, I put them in SVG wrappers as I had before and tested the ebook on the Arc -- got image distortion. SVG worked perfectly on my older-generation Kobo Touch, but out of luck with the Arc. |
|
12-07-2015, 10:47 PM | #12 |
Read, don't parrot.
Posts: 224
Karma: 110242
Join Date: Apr 2011
Device: Kindle Fire, Kobo Touch, Aldiko for Android
|
I should add the problem isn't with the horizontal images, it's with the vertical ones. In iBooks they were ballooning to the full screen size instead of 50% as coded. I don't get it. The img tags of "vertical" and "horizontal" were for the other devices, whereby if you don't set the size in the image tag the images balloon up to their pixel dimensions; they're not shrunk to fit the screen. I assumed eBooks would read the div in the CSS that limited the vertical images to 50%, but it isn't happening.
Problem is, I don't have an iPad or Mac to test on, which is why I really didn't want to do this to start with. And what started out as "Okay, no images" turned into "Couldn't we try just a few?" to "The [vertical] images are too big" but no real explanation as to what that means. Sigh. |
12-08-2015, 02:55 AM | #13 | |
Bookmaker & Cat Slave
Posts: 11,482
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
Quote:
Yes, I mean nested divs. You really need TWO divs, and, occasionally, a tag of 100% on the image as well. You set the original width on the first div--say, 50%; you set the second div to 100% of the first div, and the image to 100% of that. (I think we've also done 100-50-100, and IIRC, that works as well. Not counting 1st gens, which still have that bloody problem with images floating left at the top of the page will be overwritten with text.) When iBooks was in its early incarnations, and iPads were 1st-gen, we on occasion used one div, a paragraph, AND an image tag--but it's really the same thing. Two containers, one image. Is it the spec? Hells, no, but that's Apple for you. Hope that helps. Hitch |
|
12-08-2015, 01:26 PM | #14 |
Read, don't parrot.
Posts: 224
Karma: 110242
Join Date: Apr 2011
Device: Kindle Fire, Kobo Touch, Aldiko for Android
|
Yes, and that is why I stopped doing ebook conversions. I still do them for myself and for friends who cannot afford to hire someone like you, but otherwise I'm done with this craziness, at least when it comes to images. Images in Kindle books are easy because they are particular to Amazon, but with all the ePub apps out there, and everyone programming differently, it's a nightmare.
I'm beginning to suspect that iBooks has an option to turn off publisher formatting, like many other ePub apps do, and that this may have been the culprit from the start. Do you know if it does? I Googled it but nothing came up. I much prefer sticking to my day job, which is as a writer and editor. Language may evolve and change but at least different devices don't change the words (though give Apple time and I'm sure they'll do something there too). (That said, there was some bizarre Christian app that would change "offensive" words in one's ebooks. You would get crazy stuff like "The witch gave birth to a litter of puppies" or "You anus, I hate you!") |
12-08-2015, 05:20 PM | #15 | |||
Bookmaker & Cat Slave
Posts: 11,482
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
Quote:
Quote:
Quote:
Hitch |
|||
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Troubleshooting Quotes/Apostrophe not displaying properly | nessin | Amazon Kindle | 0 | 02-17-2013 11:30 PM |
It's Not Displaying The Book Properly Now | Nightgazer | Library Management | 4 | 11-27-2012 02:11 PM |
301 screen not displaying properly please help. | bobgoe | PocketBook | 3 | 02-01-2012 04:55 AM |
calibre 'tree' not displaying properly | wilpurina | Library Management | 4 | 04-15-2011 09:42 PM |