Wednesday, March 02, 2011

Kindle and Calibre - Creating EBooks

Something Calibre does very well is convert ebooks from one format to another. And because of that, I've been able to do something that I simply couldn't have imagined doing just one year ago. I've created a couple of ebooks. From scratch.

I'm not going to be sharing these books, sorry, but I can share how and why I made them.

Torvald and Erin Gray
The why is pretty simple, really. I'm going to be headed to Emerald City Comicon this weekend. I've been to all of them so far, and I'm happy to be going to this one thanks to the generosity of my evil twin Lisa (we're not really twins, but people kept asking if we were, so we ran with it). Anyway, to make a short story long, I do two main activities at comic book conventions. I ask nicely for free sketches, and have gotten a few, and I troll people. Both activities result in physical proof, one in the form of a sketch and the other in the form of a photograph. But until this year I've never been able to bring all the proof along with me. Two of my sketchbooks are completely filled and one of them is utterly priceless to me because of the sketches in it. I leave it in my firesafe unless I want to look at it. Bringing it to every convention so I can show off the awesome sketches in it isn't an option. I have scans of all the sketches but I haven't got permission to share them all online, so most people will never see some of the artwork in my sketchbook. As for the Torvald pictures, most of them are available online but I don't have easy access to the internet while at shows. My highest tech portable object is my Kindle. So again, until now, I had to be content with directing people to the website.

A few days ago, though, I suddenly realized that with my Kindle and Calibre, I could create ebooks for both the sketches and the troll, and be able to show them off freely, if in plain B&W, to anyone who wanted to see a particular item. It might be a little tricky to make sure I could navigate to the particular picture I wanted, but I have already played around with the ePub format a little, so I thought I'd see if I could do it.

The ePub format, fast becoming a standard for ebooks, is a very simple one. It's basically a set of html files zipped up. That's it. Now, I've been making webpages for over 15 years, so I have a pretty good grasp of basic HTML. Even better, the Torvald site was already set up in such a way that I figured it would be a piece of cake to convert it to an ePub. So I started with that. I removed all the extra formatting from the page, and simplified the layout a little. Then I zipped up the site and imported the zip file into Calibre. Once there, I converted the zip to ePub and took a look at the result.

It was a shambles. The links didn't work, and the layout was completely different. Oops.

I took the ePub that Calibre had created and examined it by saving it to my disk (right click, save to disk) and then changing the extension to zip from epub. It had a handful of extra files in it, and it had removed all my extra picture folders and put everything in the main folder. I went to another epub I'd already dissected and looked at it to see what I was doing differently. It took a little sleuthing, but I discovered that my internal links were using a different convention than the ones used by the working epub. I'd been taught to make a link to a specific place inside a page by making an "a name" tag and putting it around that place. The working epub's HTML files instead used an "id" tag within another tag. So I changed all of Torvald's internal links to id tags instead of name tags, removed a bit more garbage HTML code, and tried again.

This time it worked. I had an epub book with a table of contents that I could click on a name, and be taken to the picture of that person with Torvald. It was awesome. I converted it to mobi format and uploaded it to my Kindle, and it still worked. It's a HUGE file, 25 megs, but it's there on my Kindle so if anyone at Emerald City wants to see some particular person with Torvald, I can click a couple of times and bring up that image.

Aquaman by Todd Nauck
The sketches were harder. The website isn't one that can simply be converted, and as I mentioned earlier, all the sketches aren't on the website anyway. Plus, with these, I wanted them to be as big as possible. So I figured out what the maximum size of an image within a book is on the Kindle (520x640), found my raw images, and did a big of cropping, editing to make the contrast better, and some batch resizing and converting. With the images, all 278 of them, ready, I had to create an HTML frame to hang them on.

I divided the collection into eight sketchbooks (three Aquaman ones, an autograph one, one for images not in sketchbooks, a Doctor Who sketchbook, my husband's sketchbook, and my evil twin's sketchbook). Each sketchbook got its own page, and I made the HTML as simple as possible. Just a embedded pictures with id tags so the index could find them. I opened each page in Firefox as I finished to make sure the page were displaying properly.

Then I made two indexes. The first one pointed to each of the sketchbook pages and also to an A to Z index of the artists, which was the second index. I set that one up alphabetically, linking each artist name to the picture by the id tag. It was a bit time-consuming work, but it was to pay off.

Once I was done, I zipped it up and imported the zip file into Calibre, then converted it to ePub. The Table of Contents was a mess. It tried to include part of the A to Z index instead of just the main index.

So I dissected the ePub and copied some of its files over to my original work. There's a toc.ncx file. I edited that one down to just the items I wanted to show in the index. There's a content.opf file. That one just lists all the files in the epub, so I mostly left it alone. I also copied over a META-INF directory and it's sole file as it was, and a mimetype file as it was. Calibre also created a titlepage.xhtml file, and I copied that one over as well, because it's the file that creates the book cover. With the edited toc.ncx file, I zipped up the contents again. This time I renamed the zip file to epub, and imported it into Calibre as an epub file. It worked. Perfectly.

Next job, convert to mobi and upload to my Kindle. And it all worked. I can find an artist name in the A to Z and jump quickly to it.

So I created a couple of books for my Kindle. One from a website, and one from scratch. I'm feeling pretty good about it at the moment, though I'm far from knowing everything. I admit, I can hardly wait to get to Seattle and see my friends and family, and enjoy the convention.

If you happen to be going and want to see my efforts in person, just look for the gal in the Aquaman t-shirt carrying Torvald the Troll in a belt-pack.


Jonathan L. Miller said...

I plan on trying the "get sketches" thing this time, although I've budgeted some $$ to pay for some of them. I'll be bringing 2 books, one for LSH sketches and one for Doctor Who sketches, to give artists a choice if they have a preference. This is my first time; do you have any suggestions? Should I ask for a sketch first, then ask if the artist charges, or...?

Tegan said...

Ask if they do sketches, as many do not, depending on the circumstances. Then ask how much they charge, showing them your books at the same time so they can see what kind of size they would be drawing.

Free sketches are getting harder to get, as too many jerks get a free sketch then turn around and sell it on eBay the next day. So, if you have a bound sketchbook with a few sketches in it already, then it's easier to convince people you aren't going to resell it.

Jonathan L. Miller said...

Yeah, I made sure to get bound books where pages couldn't be torn out easily. I know at least one artist who'll be there who will do a sketch in one of them, so hopefully I'll have a start. :-) Thanks!