Showing posts with label iPad. Show all posts
Showing posts with label iPad. Show all posts

Thursday, May 16, 2013

Video in Kindle books, thanks to EPUB3

Yesterday, I wrote about how you can call external audio/video files in an EPUB3 document. This works brilliantly in iBooks and Readium, but so far, nowhere else. What happens when it doesn't work is actually pretty interesting. According to the spec, you can add a fallback message, and indeed a fallback photo or link. In this case, I've used the poster image as a fallback image.

<p>Does everyone have their own cat videos? I sure do. Here are Nighty and a very small Momo playing the box game.</p>
    <video controls="controls" poster="image/poster.jpg" width="384" height="276">
    <source src="http://www.elizabethcastro.com/epub/examples/catbox2.mp4" />
    <source src="http://www.elizabethcastro.com/epub/examples/catbox2.wvm" />
    <p><a href="http://www.elizabethcastro.com/epub/examples/catbox.mp4"><img id="poster" width="384" height="276" src="image/poster.jpg" alt="poster" /> Click to play the video</a> and then return to read the rest of the book. </p>
    </video>


The only problem is that Adobe Digital Editions is the only EPUB ereader that properly displays the fallback message.

Adobe Digital Editions - video fallback

But it's nice. If you click the link, your default browser opens, and the video plays.

Unfortunately, if you open the EPUB file on the NOOK, or in Kobo (even the Kobo for iOS app), or even if you open it in iBooks without internet access—and thus the video cannot be displayed—you get varying things—sometimes the poster image, sometimes controls but no video—but no fallback content.

Kobo - no fallback

Fallback leads to video for Kindle books

But what about Kindle? Suppose you take that EPUB3 file, and pass it through KDP, or Kindle Previewer, or KindleGen, which all do the same thing—convert an EPUB file to KF8/mobi. And yes, they work on EPUB3 files as well as EPUB2 files. Next, open that converted mobi file in a Kindle Fire.

The fallback text, photo, and link appear, and better yet, when you click the link, Kindle Fire sends you to the browser, and plays the video. When you're done, the back arrows take you back to the book.



If that's not enough, stick it on Dropbox, and open your Dropbox app on an iPad. Once it's been copied, click the Open in another application arrow (upper right corner) and choose Kindle for iOS. Again, the fallback text, photo, and link appear, and when you click them, the video plays. It's true that you get an error message, but I'm guessing there's a way to get around that, but regardless, the video plays anyway. As if it were in a special window inside the Kindle iOS app. And when you've finished watching the video, click Done, and you go right back to the book.




So let's sum up:

1. So far, you can only play an embedded video right on a page in an ebook in iBooks and NOOK. But B&N won't let self- and indie publishers add such books to Pub It!.

2. You can play external video files right on a page in an ebook only in iBooks.

3. The fallback text doesn't appear in NOOK or Kobo.

4. The fallback text does appear in ADE and—if you convert the EPUB3 file to KF8/mobi—it also appears in Kindle Fire and Kindle for iOS (perhaps other Kindles too?), and all of these let you play the fallback video in an external browser.

5. An added caveat: I haven't uploaded a book to KDP with a link to external video. I can't guarantee that such a thing is permitted.

6. This opens up a lot of possibilities.

You can download the mobi file here. And if you liked this post, consider subscribing to my blog so I have time to write more!

Tuesday, November 27, 2012

Versioning in iBooks (part 2)

Yesterday, after confirming that the new version of The Monarch Butterfly Book had not yet gone live, I called Apple's iBookstore support line—(877) 206-2092 in the US, see end of post for other countries' numbers—and asked what was going on. The guy was very helpful, told me that everyone had been on vacation between November 16 and November 25th, due to the Thanksgiving holiday (about which he and I both decided we were envious), but that they were back yesterday and should get to it shortly.

He also checked that I had the "What's New" material already included, which I guessed indicated that was a sticking point in many updated versions. (Remember to use the latest version of iTunes Producer to include the What's New information.)

And finally, he said he'd escalate my issue so that it would get solved as soon as possible. I almost, in the interest of science, told him not to escalate it, so that I could see and report on the real process, but sorry, dear reader, in the end, I did not.

About 12 hours later, I got the email from Apple confirming that the new version had gone live.

And this morning, I opened iBooks on my iPad and iPhone to see how those changes would be announced. What I saw was that iBooks adds a number to the Store button to indicate how many updates a reader has available, but doesn't indicate which book is affected:

iBooks updates

iBooks versioning on iPad

When the reader presses the Store link in iBooks on the iPad, they will see Update buttons next to the corresponding books:

iBooks versioning on iPad

On iBooks on the iPhone, going to the Store will display an Updates link:

iBooks versioning on iPhone

And when your reader follows the Update link, they'll see which books can be updated:

iBooks versioning on iPhone What's New?

At that point, and only on the iPhone as far as I could tell, the reader can click the What's New arrow to see what has changed in the new version:

iBooks versioning on iPhone

Once they click the Update button, the new version downloads to their device, and initially will be displayed with the blue "New" banner:

iBooks versioning: New banner

Once the reader has looked at the book, they won't be able to tell which version they have. I couldn't figure out any way to get information about a book's version from within iBooks on the iPad at all, or on any device once the update was downloaded. This is a serious shortfalling for what I believe is a very valuable feature.

The only way for the reader to see the versioning information of an existing book, including what has changed from version to version, is to go to the iBookstore, look up the book, scroll down to the bottom of the Book Description or Details area, and check the What's New section.

iBooks Versioning

The reader can also get a full rundown on the differences from one version to the next by clicking Version History. I think it's rather confusing to use a header like "Version 3.0" when what they mean is that the changes listed are for the EPUB3 version of the book. It is only below that you see the version number that I gave the book: 1.1.

Therefore, you might want to add version info to one of the pages of your book (the copyright page perhaps?) if you want readers to be able to tell which version they have. (I'll do this next time.)

iBooks Versioning info

So, still some wrinkles to be ironed out, but I continue to think that versioning is a brilliant idea. Now I have to update some of my other books so I can see what happens with notes and bookmarks (which aren't allowed in a Fixed Layout book like this one.

There were two major errors that were fixed in this version of The Monarch Butterfly book: some arrows that were in the wrong place on page 24, and something much more important, which I'll discuss in my next post, about JPEGs and PNGs.

You can buy The Monarch Butterfly Book on the iBookstore (and thus be notified as described above about new versions), or directly from me (via Kagi) (in which case I'll notify you personally about new versions to this book as well as any new books via email).



Here are the iBookstore support telephone numbers:

Australia: 1300 307 504 (Note that this is a low tariff number.)
France: 0805 540 117
Germany: 0800 664 5307
Italy: 800 915 902
Netherlands: 0800 0201 578
Spain: 900 812 687
U.K.: 0800 975 0615
U.S.: +1 (877) 206-2092
Toll-free from U.S. and Canada.

Friday, November 16, 2012

Versioning in iBooks 3 (part 1)

Another promising new feature announced by Tim Cook about iBooks 3 is the ability to make updates to an ebook, and then make those updates available to readers who have already bought the book. There were a few minor errors in my Monarch Butterfly book so I decided I would use it as a guinea pig to test versioning.

The first thing to note is that versioning only exists for EPUB 3 documents. They can be flowing or fixed layout, but they have to be EPUB 3.

So, my first task was to update the Monarch Butterfly fixed layout book to EPUB 3.

Changes to the OPF file

I began with the OPF file, adding version="3.0" to the initial package element and adding the namespaces that Apple recommends.

I updated the title of my book to indicate the version number, though I'm not sure this is necessary (or desired).

I added the required modification date and time:

<meta property="dcterms:modified">2012-11-06T12:00:00Z</meta>

Pay special attention to the time format: CCYY-MM-DDTHH:MM:SSZ. I tried putting just the year, and EpubCheck gave me an error. Note that both the T and the Z are required.

To make sure my fonts are recognized, Apple now requires this line instead of the com.apple.ibooks.metadata.plist file:

<meta property="ibooks:specified-fonts">true</meta>

And then comes the part where Apple lets you specify the version of your book. You are allowed two dots and three components (so 1.2.1) and up to four numbers per component (which seems excessive, frankly). And these aren't decimal numbers: trailing 0's count to keep them ordered; 1.10 is later than 1.9.

<meta property="ibooks:version">1.1</meta><!--controls versioning in iBooks3-->

Then, since my book is fixed layout, I had to add the EPUB 3 specific metadata:

<meta property="rendition:layout">pre-paginated</meta>
<meta property="rendition:spread">auto</meta>
<meta property="rendition:orientation">auto</meta>


Because my books' pages include Javascript, I had to add properties="scripted" to each of the pages which links to a Javascript file, even if it didn't use Javascript in that particular page.

<item id="milkweed" href="milkweed.xhtml" media-type="application/xhtml+xml" properties="scripted" />

And then I removed the guide section, which is no longer required by Apple (and was already deprecated in the EPUB 3 spec).

</spine>
<!--new to 1.1 guide is removed -->
</package>


New TOC file

EPUB 3 requires a new XHTML-based TOC file, which is a lot easier to write than the old toc.ncx format, since it's just formed by an ol list with links to the various TOC entries. For a Fixed Layout book, for which you want iBooks to create its graphic TOC (made of the covers of the books), just create a single entry to the first page, or cover in my case:

<nav id="toc" epub:type="toc">
<h1 class="chapter">Table of Contents</h1>
<ol>
<li><a href="title.xhtml">The Monarch Butterfly Book</a></li>
</ol>
</nav>


Then, as a replacement to the guide section, add a landmarks section, which works very similarly:

<nav epub:type="landmarks">
<h1>Guide</h1>
<ol>
<li><a epub:type="ibooks:reader-start-page" href="title.xhtml">The Monarch Butterfly Book</a></li>
<li><a epub:type="cover" href="title.xhtml">Cover</a></li>
<li><a epub:type="bodymatter" href="milkweed.xhtml">First page</a></li>
</ol>
</nav>


Finally, declare the new toc.xhtml file in the OPF file, paying special attention to the properties attribute:

<item id="toc" href="toc.xhtml" media-type="application/xhtml+xml" properties="nav"/><!--new in 1.1-->

That's it for the OPF file.

Changes to the XHTML files

In each of the XHTML files, I had to change the meta tag where I declared the character set. It was:

<meta content="text/html; charset=UTF-8" />

and it should be:

<meta charset="UTF-8"/>

I also had a few documents that somehow still had extraneous DOCTYPE elements. I got rid of those and made sure that each XHTML document started like this:

<?xml version="1.0" ?>
<html xmlns:epub="http://www.idpf.org/2007/ops" xmlns="http://www.w3.org/1999/xhtml">
<head>


There were also a few places I had erroneously used character entities, things like &copy; to show the © symbol. Now that I had the proper character set declaration, that was no longer necessary (or allowed). So I simply removed the character entities and replaced them with the characters themselves, typed in directly.

<p>Copyright ©2012 by Elizabeth Castro...

As far as content, I also fixed the error on page 24, which had the blinking arrows in the wrong place:

Wrong arrow placement

And put them where they go:

Correct placement of arrows

I also changed the Javascript so that the arrows would blink more slowly. People seem to have had difficulty finding the captions. It's actually a tricky problem. I want the photos to be displayed without distractions, but I want to offer clues. I haven't quite found the perfect solution yet.

Validating

Once of all of the changes were made, I used EpubCheck to make sure I had done it all correctly. I used the latest version: EpubCheck3RC.

Uploading the new file to the iBookstore

Finally, I uploaded it to Apple's iBookstore with iTunes Producer. When you make changes to a book that already exists, you only have to change the parts in iBooks Producer that are different, and it will only update those pieces of your package. So, I updated the description and then on the Assets page, I clicked the Choose button under Publication, and selected the new updated EPUB file. This screenshot is actually after I've done that. iTunes Producer doesn't give a lot of feedback.

Upload new file in iTunes Producer

And then I got the error I was suspecting:

Versioning error

I was expecting it because Apple says that you have to say what changed in a "Version_whats_new" XML file. I hadn't been able to find where that was.

It turns out I had downloaded the latest version of iTunes Producer, but I hadn't installed it. Once I did that, I was able to add the What's new information on the Book page:

iTunes Producer: What's New

Then I delivered the package again (no need to upload the book files again), and it went through without a hitch.

What I am most interested to see now is how it notifies me (and all of you who have purchased the book through the iBookstore) about the new changes. The new description went live almost immediately, but when I go to iTunes Connect, it tells me that the EPUB 3 version is under review.

iTunes Connect-3

And indeed, I don't see that little update icon that Tim Cook promised. Though I'm left with questions: When does iBooks check? Does versioning only work in iBooks 3? Do I have to open and close the app to force a check?

Update versioning, not yet

When I go to the Purchased section of the iBookstore, I also see that it shows that the book was already downloaded and I have no opportunity to update it. I assume that when the changes go live, this button will change.

Already downloaded

If you haven't bought the book yet, you'll be able to tell if you have the new version by checking page 24 and clicking the info arrow to see where those arrows show up.

And I'll keep you posted about how long it takes to go live. It seems like a really important feature to me. I would have liked to add a note or bookmark to see if those are maintained, but fixed layout format doesn't allow them. I'll have to update one of my other books...

Wednesday, October 31, 2012

New Contract needed for new iBookstores

I got an email from Aaron Shepard, POD expert, this morning, letting me know that it's not enough to add your books to the new 18 iBookstores (Latin America and New Zealand) that Apple made available last week. You also have to download and accept the new contract addendums! Argh. So glad he told me.

Quick overview:

First, add the new territories to your books. Start by going into iTunes Connect and clicking Manage Your Books.

Manage your books

Next, click the cover of the book to which you wish to add territories.

On stores-1

Notice that the book on the right just says "32 stores", but there are currently 50 total possible. That means I need to add the remaining 18 new territories.

You can also see, under the Read Aloud EPUB book on the left, that I had already added the new territories to this book, but the book has still not been accepted into the new territories.

Next, you'll see the summary page for the chosen book. click the Rights and Pricing button in the upper-right corner.

Rights and Pricing button

iTunes Connect will show you the current list of territories where your book has been added, along with the Sales Start Date, DRM, Price, and other data. Click the Add New Territories button in upper-left corner.

iTunes Connect Rights and Pricing list

Choose a DRM option, Sales Start Date, Base Currency (sales in most Latin American countries in their own currencies is not available, with notable exception of Mexico), Publication Type, List Price (of print edition), and Suggested iBookstore Price (which must be less than List Price). Then check the boxes next to the territories you wish to add. Or click Select All. Then click Continue.

Add New Territories dbox

iTunes Connect now shows you a list of the new territories and the price for each one. You are not limited to this price. Go through the list and adjust as necessary. (The book shown here is free, so the price is 0 in each case.)

Confirm New Territories

Click Confirm when you're ready. Now you'll be back at the Rights and Pricing list, with the new territories added. But notice that they're still Not On Store. (Aaron tells me that if you click on the Not On Store label, you can see what the problem is.)

New Rights and Pricing

Click Done three times (always at bottom right of window) to get back to the iTunes Connect main window.

Now click Contracts, Tax, and Banking on the left side of the main iTunes Connect window.

Contracts, Tax, and Banking

Click Request next to the new Contract amendment. I recommend downloading and reading the document. If you agree, click the appropriate box and then click Submit.

Two more Done buttons and you're, well, done.

Now when you go to Manage Your Books, you'll see that your books are available on all 50 stores.

On 50 stores

And if you visit one of the new territories in iTunes (by clicking the flag button in the lower-right hand corner and then choosing the desired country), you'll see your books listed. It might take some time for the new iBookstores to properly index your book's search terms. At first, I was unable to find my books, even by searching on my name. Searching on ISBN does seem to work, and I'm hoping that that will get updated quickly.

Mexico iBookstore

Note that my book that sells for $5 in the US sells for 65 Mexican pesos which, according to Google, is indeed the going rate.

One more thing I learned last week: reviews are posted only in the iBookstore that belongs to the country of the person who wrote the review. So, there is a lovely review of the Monarch Butterfly book by Laura Brady which I can only see if I connect to the Canada iBookstore:

Monarch Butterfly review, by Laura Brady

and folks who connect from countries besides the US cannot see the five five-star ratings that the book has in the US iBookstore.

In US iBookstore

I think it would be nice if Apple made those out-of-country reviews available (perhaps after reviews from one's own country?) If it's the same book, this is information that would be useful to all.

At any rate, keep in mind that if you want to see reviews of your books in other iBookstores, you'll have to go to each store individually. And if you've reviewed my book on a non-US iBookstore, please let me know. I'd love to see it. (And thanks!)

Monday, October 22, 2012

Presenting “The Monarch Butterfly: An Interactive Picture Book”

Over the weekend, I finally finished my first serious attempt at an interactive picture ebook. I've been working on it off and on for several years, first as I tried to take photographs that were worthy of being published, and second as I taught myself enough Javascript to create the effects that I thought were necessary to show the photographs and information in a fun and beautiful way.

Here's a short sampling of the book:



You can download a sample, or buy the whole book on the iBookstore. It works great on both iPad 2 and 3, as well as newer iPhones. I haven't tested it in other readers besides iBooks (yet).

I am writing a new miniguide that explains how to create interactive ebooks with Javascript and CSS and will announce that as soon as it's available.

If you would like a review copy, please contact me.

Tuesday, October 2, 2012

Retina images in iBooks on iPad

I've been promising this post for several weeks and I think I finally have a definitive recommendation. But let me start at the beginning. The goal is to include beautiful high-res images in ebooks that take advantage of the Retina display, making sure to follow Apple's rules and not completely bloat the book, especially on lower-res displays.

So, I went to James Duncan Davidson who has done some pioneering work serving Retina images on websites. First, he found an issue with WebKit and Retina images. Then he showed it was possible, and what a difference it makes. Then, he speculated about need for progressive JPEG. And recently he figured out how to serve Retina images to Retina displays without bogging down slower screens. All very helpful.

At least for websites. Of course ebooks have different issues. First and foremost, since they are self-contained, it doesn't make sense to serve different images in different situations, unless you're creating completely different EPUB files, which is a hassle of its own.

Second, on the iPad 3, which has a resolution of 2048 x 1536, we have the added problem that iBooks doesn't allow images larger than 2 megapixels, and 2048 x 1536 is 3,145,728, precisely 1,145,728 pixels too many.

So how do we get Retina quality images in an ebook in iBooks?

First, following the guidelines in my last post on maximizing the iPad screen real estate, as well as providing lots of zoomability, I'm going to use a viewport that measures 2400 x 1860. And I'm going to create images at that size as well.

To get around the 2 megapixel limit, I worked out a technique based on an idea on Dan Amos' Book Creator website: “chop your 3.1 million pixel image into smaller images with each no larger than 2 million pixels. Then just line them up on the page.” First, I created an image that measured 2400 x 1860 (using the selection tool with a fixed ratio of 2400 x 1860 to select the desired area of my photo, then Save to Web at exactly 2400 x 1860).

I calculated that at 2400 pixels wide, a 2 megapixel image could have a maximum height of 833 pixels (2M÷2400). But that's an annoying number, so I opted for slices measuring 2400 x 800 pixels high. I set horizontal guides at 800px and 1600px and after activating the Slice tool (jumbled in with Crop), I clicked the Slides from Guides option in the toolbar. Then, I switched to the Slice Select Tool and double clicked each slice to name it. Finally, I chose Save for Web, Photoshop exported the three slices for me, with my chosen names (top, middle, and bottom).

In the HTML, I positioned each image right after the next with no spaces:

<div><a id="image" href="#pag001"><img id="item1" class="item" src="molt/top.jpg" alt="image" style="width: 2400px; height: 800px; z-index:-1" /><img id="item2" class="item" src="molt/middle.jpg" alt="image" style="width: 2400px; height: 800px;z-index:-1 " /><img id="item3" class="item" src="molt/bottom.jpg" alt="image" style="width: 2400px; height: 260px;z-index:-1 " /></a></div>

And in the CSS, I set the images to display as if they were block elements (one on top of the next):

img {display: block}

And the images display fine, and everything looks beautiful

2400x1860

And if I place a 900 x 698 pixel image on the right side page, flipped so that the same bits are next to each other, you can really see the difference:

big vs 900 x 698

Especially if you zoom in:

big vs 900x 698 closeup

But here's the thing. If I place a 1600 x 1240 px image on the right hand page (again, flipped so I can compare the caterpillar heads with each other), I can't tell the difference. Maybe you can. And perhaps that makes sense, I'm not sure. A 1600 x 1240 image (which is less than 2 megapixels) is only 206ppi and not officiall Retina quality, compared with the 264ppi permitted by the iPad 3, but it's pretty darn good.

2400x1860 vs 1600x1240

Even if you zoom in:

1600 closeup

So, given that

1) Slicing high-res images is a pain (and sometimes reveals white dividing lines on iPhone and old iPad)
2) My high-res caterpillar takes up 2Mb, compared to the 1Mb for the 1600 x 1240px image.
3) The difference in quality is minimal.
4) The difference is even less noticeable on iPhones and older iPads.

I don't think going for extra high-resolution images that take full advantage of the new iPad's Retina screen is worth the trouble.

But I'd love to hear if you've found differently.

Finally, this is a fixed layout example, but I would say this goes double for flowing books, in which it would be even harder to position three images together reliably.

Want these posts emailed to your inbox? Would you like to see the example files that I used? Receive a discount on my books? And earn my eternal gratitude? Be sure and subscribe!

Thursday, September 20, 2012

Maximizing zoom via the viewport in Fixed Layout ebooks in iBooks

I got an email from one of my readers the other day saying I was giving him a headache. Well, watch out, because I'm not done yet :) Bet you didn't know I used to be a math major...

Let's forge ahead. Although, as we've seen here and here, when you specify a viewport, you're actually specifying the proportions of the viewport, it turns out that you're also specifying the amount of zoom possible. Basically, if you use small numbers for the viewport, you'll have less zoom than if you use large numbers. Let's look at an example.

First, let's suppose, giving the calculations from Friday, that we want a viewport whose proportions take advantage of the iPad's screen with as little letterboxing as possible. We also want individual pages for each image. That means the viewport's proportions will be 1900 x 1470px.

You might be alarmed that 1900 x 1470, when multiplied together is larger than 2,000,000, which, if you had images that size, would cause your book to be rejected by Apple's iBookstore. But, just because your viewport is a certain size, does not mean that your images have to be that size, even if you want them to fill the page. They simply have to be displayed at that size.

But again, what numbers should we use for the viewport, if the proportions are 1900 x 1470, or a ratio of 1.29:1 (which is just 1900/1470)? A simple option would be to set the viewport to 1290px x 1000px (which of course, also has a ratio of 1.29:1).

<meta name="viewport" content="width=1290,height=1000" />

Now, what is the largest image that we can put in that viewport that will display full size? To get this number, multiply the ratio by 2 million (in our example 1.29 x 2,000,000 = 2,580,000), and then take the square root of the answer (1606). That number is the biggest width a 2 megapixel image of these proportions could have. If you like, round it off to make it easier to remember and type (1600). Divide the width by 1.29 to get the height (1240). And if you like, multiply them together to make sure you did it right. You should get a number that is less than 2,000,000 (1,984,000).

Next, save your images at 1600 x 1240px.

Add the images to your pages, and preview in iBooks. Here's the page at full size.

1290x1000viewport

But with a book like this, your readers will want to zoom in. Here's the same page, zoomed in as far as it will go:

1290x1000 zoom

But what happens if we use a larger viewport? Let's try the full 1900 x 1470, which, as you remember has the same 1.29:1 ratio as 1290 x 1000px.

<meta name="viewport" content="width=1900,height=1470" />

I'm not going to change the images at all. It's the same 1600 x 1240 image I used in the previous example. (Though I did change the CSS to display the image at the same width as the viewport, 1900px wide.)

At full size, the page looks exactly the same. It's counterintuitive, but makes sense if you think about it. Just remember: the viewport determines the proportions, not the actual size.

1900x1470 full size

But look what happens when you zoom in. Specifically, notice how much farther you can zoom in:

1900x1470zoom

And what if we made it bigger still. Let's try. I'll pick 2400 pixels wide, just because it's relatively even number. If the width is 2400, I just have to divide by 1.29 to get the height (1860).

<meta name="viewport" content="width=2400,height=1860" />

At full size (it still fills the screen with no letterboxing), it still looks exactly the same as the other viewports with the same proportion. Note that I'm still using the same image that meaures 1600 x 1240px:

Viewport 2400x1860

But now you can zoom in even further:

2400x1860 Zoom

Now, I'm not sure what the limit is. Surely, it doesn't make any sense to be able to zoom in so far that the image is totally blurry or pixelated. However, in a book where zooming in is important, you want to make sure you don't use puny viewport numbers.

I also am not sure if there is an upper limit to the viewport that Apple or iBooks will allow. When I tried to create a viewport that measured 4800 x 3720px, it opened, but crashed when I zoomed in and out of a page. All of the sizes shown on this page work just fine.

Ah, and you might ask, what about the image size. How can we make the zoomed in images look their best. That's tomorrow :)

Note: This is a picture of a Monarch Butterfly egg. Notice the pin head in the upper-left corner of the picture for perspective on its size. This particular egg was just about to hatch (it's on the next page in the book!) They are truly amazing creatures.

Wednesday, September 19, 2012

Book Proofer, Caching, and iBooks

I just posted an update to my blog post about choosing a proportion for the viewport in Fixed Layout EPUB ebooks. I got some figures wrong originally because even though I had changed the EPUB and thought I was looking at the latest version, iBooks was holding out on me and showing me an older version.

I often use Book Proofer, especially when I'm working on Fixed Layout ebooks for the iPad. Book Proofer is a free tool that you can get if you have a full iTunes Connect account. (There are two kinds of iTunes Connect accounts, one for making books available for free and one that lets you sell ebooks through the iBookstore. Apple makes some tools available to holders of free ebook iTunes Connect accounts, but unfortunately, they only give Book Proofer to those who have signed on to sell ebooks through their store. What do you need to get the full account? One ISBN, a US Tax id, and your bank information. In my opinion, it's totally worth it, and you get the ability to sell ebooks as well.)

So what does Book Proofer do? When you drag an EPUB folder (you can drag a zipped EPUB, but why bother?) on top of the Book Proofer window, the book automatically syncs to iBooks on any connected iOS device that has iBooks open. Almost instantly.

And then, you can make changes to the XHTML and the CSS files and see the changes updated in the iPad on the fly. Book Proofer is really an invaluable tool for creating Fixed Layout for iBooks.



I found out on Tuesday, however, that not all changes are updated right away. I was playing around with the viewport size, trying to see if I could find a perfect horizontal page size that would fit perfectly and take maximum advantage of the iPad's screen. It turns out that Book Proofer won't update changes to the viewport. Let's see:



Now, anybody who has been working with iBooks for the last two years is probably familiar with its peculiar caching issues. I first discovered that iBooks wouldn't show you the latest version of an ebook unless you both deleted the iTunesMetadata.plist file from the EPUB and also changed the value in the dc:title value in the OPF file.

But, on Tuesday, I couldn't make that work. I think part of my problem was the order in which I was making the changes. Since I wanted to change the OPF file, the three XHTML files and the CSS file, I made the changes in whatever order I found the files on my desktop.

Not only that, sometimes I made the changes with the ebook open in iBooks, and sometimes I went back to the list.

I have found that the order matters, and sometimes you have to go back to the list.

So, if you want to change the viewport, first make and save the changes in the XHTML and CSS. Then, change the value of the dc:title element. When you save, iBooks should automatically close your document and display your list of EPUB books. It will replace the older ebook with the newer titled one. When you open that new document, you should find that the viewport has been properly updated.



Changing the dc:identifier element also works, as long as you do so while the book is closed. It also has the added benefit of creating an additional book instead of replacing the previous one, which can be helpful if you're trying out a series of changes and want to be able to go back and revisit earlier ones.

You can also change the dc:date element to track when the changes were made.

The important thing to remember is to make the changes to the XHTML and CSS files first, and only then change the dc:title, dc:identifier, and/or dc:date.

Friday, September 14, 2012

Choosing a viewport's proportions in a Fixed Layout EPUB for iBooks

UPDATE: September 19, 2012. Well, unfortunately, the numbers given for the individual horizontal pages were not quite right. Which is strange, because the screenshots sure make it look like it was right. I'm still trying to track the problem, though I think the issue is caching, which I hope to get into in more detail in a separate blog post. For now, know that the faux pages take up 120px (because of the higher resolution of the Retina display!) and so the actual optimal size of full screen individual pages is 1900 x 1470.



Yesterday, I showed you how the specified Viewport size affects the size of text and images in a fixed layout ebook in iBooks. Today I want to go over in more detail how you should choose the viewport's proportions.

The first thing to remember is that even though you specify the viewport size in pixels, it's not really a fixed size, but rather a proportion. For example, if you specify a viewport of 1000px wide by 1000px wide, you'll get a square page, but on an iPad3, it will be displayed at some other number of pixels, but not necessarily 1000.

When viewing a two page spread, it will look like this:

Square Viewport

And when you zoom into a single page, you get this:

Square viewport single page

Note that even though the viewport was defined as 1000px square, its actual measurement in pixels depends on its zoom factor. When zoomed into a single page, for example, it measures about 1470px square. When viewed in a spread, an individual page measures 997px square. That's awfully close to 1000, but it's just a coincidince.

A page whose viewport is set to 2000 x 2000px would also be displayed in a spread at almost 997px square. Actually, it measures 1010px square, because the faux pages are smaller and take up less room.

Viewport 2000pxsquare

(If you're wondering why the image shrunk, go back and read yesterday's post.)

More importantly, when you have a square page viewed in a spread, there is a lot of letterboxing. And when you zoom in, you'll see as much of the facing page as fits in the space left over from the square:

Square page zoomed

Now what happens if you turn the iPad sideways? Viewing a spread of square pages makes them pretty small.

Square pages spread in vertical iPad

And when you zoom in, there's a fair bit of letterboxing above and below, and not so much room for the facing page.

Square page in a vertical iPad

So, how do you take advantage of the real estate?

Of course, if your book is designed to be square, there's not much to do about it, but if you're designing a new book, or have some leeway for adjusting an existing design, you can choose a viewport that better takes advantage of an iPad's screen.

There are two options in this vein. You can either choose to have a spread of facing pages fit on the screen, or you can have a single horizontal or vertical page fit on the screen. Let's look first at the facing pages option.

Suppose you want to create a book whose spread fits into landscape orientation view on the iPad. If the iPad measures 2048 x 1536, and you leave out 64 pixels for top and bottom real estate and 56 pixels for faux pages on the ends, you get 1984 x 1480px. If you have 1984px for the entire width, that means you'll need to set the width of one of the pages to exactly half that, or 992px. The height of each page will still be 1480px.

In this particular example—more Monarchs!—I filled the left page with the left half of an image and the right page with the right half of an image. So the spread looks like one large image, with only the telltale faux spine in the middle giving it away.

Landscape Spread Fill iPad

Now, I will admit that if you double click the spread, it moves the tiniest bit. I don't know if there is a perfect size that eliminates that. If there is, I couldn't find it. (This is different from the weird flicker that you get sometimes when flipping to a new page. That is a different problem altogether.)

You can't zoom in on that page because it already fills the screen.

If you turn the iPad sideways, you get letterboxing above and below, as you might expect,

Horizontal spread in vertical iPad

but when you zoom in on a single page, it fills up practically the entire screen with no letter boxing and a minimal overlap of the facing page.

Horizontal spread on vertical iPad, zoomed

It's pretty good.

What happens if you change the viewport to 1984x2960? Note that that is precisely double the size we were using.

Once you change the width of each image to 1984px, it looks exactly the same:

Double horizontal viewport

There is one important difference, however, which I'm going to save for another post.

Until then, let's look at other options for the viewport. While you could create facing pages that would fit in a vertical screen, they'd be really skinny. There might be a reason to do that, but I'll leave it for you to figure out.

Instead, let's look at how to maximize the real estate of individual pages. There are a couple of reasons why you might favor individual pages instead of a spread that combines two pages into one. First of all, it's simply a different look to turn an entire page rather than turn a half of a page.

But secondly and more importantly, you can only apply Javascript within a single page. So if you want to activate something on the right side by doing something on the left side, you'll have to have both sides in the same XHTML document, that is, in an individual page.

Individual pages that maximize screen real estate

We've actually already seen how to maximize portrait orientation pages. Just use the same measurements as we did for the spread, but fill the right and left pages with distinct material.

Let's look instead at horizontal pages. Again, if we're starting with 2048 x 1536, then we have to subtract 64 for vertical real estate, 28 for the faux pages at one end, and 120 pixels for the minimum overlap of the facing page. That leaves us with 1900 x 1472px, which I'll round off to 1900 x 1470px so it's easier to remember.

Since each page is going to be independent, each image must occupy the full terrain, 1900 x 1470px.

If you view the book zoomed out, the pages are rather small:

Individual full screen horizontal pages iBooks iPad

But if you zoom into a single page, it takes up the full space available in horizontal orientation:

Zoom of individual full screen page iBooks iPad

Other sizes

Of course, you can make a book any proportions you wish. You simply have to keep in mind that, as with the square example, there will either be a fair bit of letterboxing when the reader is zoomed out, or a lot of overlap from the adjacent page if they're zoomed in.

What about zoom?

I know, I keep hinting about zoom, and it's really important. But it's going to have to wait until Monday, independence or no.



More of my books