Webomator: Bradley W. Schenck's blog
Bradley W. Schenck's books Webomator Blog Topics Archives Retro Sci Fi
Search retro robot art
Subscribe RSS retro future Bradley W. Schenck at Facebook Bradley W. Schenck at Goodreads Bradley W. Schenck on Twitter Bradley W. Schenck at DeviantArt Bradley W. Schenck Also by Bradley W. Schenck I play games.
An easy way to build smaller .mobi files for the Kindle and Kobo readers

Filed under Can't Stop Thinking, Works in Progress

If you’ve ever converted an ePub file to a .mobi file while making an eBook, you’ve probably noticed that your .mobi file is easily twice the size of the original ePub. The reason is that the Amazon tools for building .mobi files put more than one version in that single file.

This doesn’t matter, if the only place you’re selling the .mobi format book is on Amazon. That’s because when you upload your .mobi to Amazon they store it in more than one format: then when someone buys the book, the correct format for their device is sent to them. So when Amazon delivers your book it will be roughly the same size file as the original ePub.

But what if you’re making the Kindle version available through your own web site? Your users are going to be saddled with a large file – maybe a huge file – because that’s what Amazon’s tools build. This may not matter so much for a book that’s all text, plus its cover; but it does matter. And if you build an illustrated book? Then it can matter a whole lot.

The Lair of the Clockwork BookI’ve been working on an eBook edition of The Lair of the Clockwork Book. This is a book that has over one hundred and twenty illustrations; even when I convert them to greyscale the ePub ends up at around twelve megabytes. So the Kindle version built by the Kindle Previewer program is about twenty-four megabytes. If I make that book available for download from my own web site, we’re looking at a gigantic file.

For the past few years I’ve been formatting eBooks for Matthew Hughes. Over that time I’ve looked into the problem of .mobi file sizes more than once. The problem is that Kindlegen (the engine that does the actual conversion for Kindle Previewer) isn’t documented very well; and when you do a Google search for solutions to the problem you end up with a lot of results that aren’t helpful at all. Most of these turn out to be from Calibre users.

Calibre’s a very popular end-user tool for converting and editing eBooks. It’s never been any use to me, because once it gets its claws on an eBook it trashes the original CSS. That’s something that doesn’t seem to trouble its users, but it certainly troubles me. So although I’ve tried using a couple of Calibre plug-ins for working with .mobi files, the results haven’t ever been usable.

But this merely irritating problem with the .mobi file size became a real, terrible problem for The Lair of the Clockwork Book. So I had to look farther, and try harder, to find a real solution. And I finally found it here.

That article describes an obscure command line argument for Kindlegen that produces a simple, one format .mobi file. This .mobi file is about the same size as the original ePub (actually a little smaller, in my case). There’s a possible wrinkle here if you also want to provide an .azw3 version for Kindle users; I’ll address that at the end.

I was thrilled to discover that this works. But it was pretty complicated to use. This was partly because it’s been years since I spent much time in an MSDOS command console, but entering modern Windows paths, using quotation marks where there are spaces in directory names, was just so cumbersome that I figured there had to be a better way. There is!

Yes! This IS Rocket Science

You can write a .bat file to perform this conversion for you. So in order to make a stripped-down, single format .mobi file for the Kindle or Kobo readers, you just drag your ePub file’s icon onto the icon for the batch file.

The only tricky thing here is that you may need to edit the path to kindlegen.exe, which could be different from the one I’m showing below; and if any of the directories in the path use spaces you’ll have to use quotation marks around them, as you see in the example.

So start up any text editor – Notepad is fine – and begin by pasting this line into a blank document:


C:\"Program Files (x86)"\"Kindle Previewer"\lib\kindlegen.exe -dont_append_source %*

Here I’m assuming that your copy of kindlegen.exe was installed when you installed the Windows version of Kindle Previewer, and that you installed it on your C: disk. If you’ve installed Kindlegen someplace else, you’ll need to edit the path to Kindlegen. Notice how directory names like “Kindle Previewer” are surrounded by quotes. So in your own file you should edit the path to Kindlegen as needed.

Save this file with a .bat extension. I called mine makekindle.bat, but you can call it anything you like. Save the file someplace you’ll remember.

Now you can build your own smaller .mobi files just by dragging an ePub file onto the .bat file’s icon. (Even if there are spaces in the ePub’s file name!) The new .mobi file will be saved wherever the ePub file is.

Note this, though: the error report for the conversion will disappear in an instant. You should always build a file first with Kindle Previewer, just because that’s the only way you’ll see a list of the errors Kindlegen may have encountered.

Now we’re at the end, so it’s time for me to tell you how to get an .azw3 version if you also want one of those.

This is really easy if you have a Kindle: take the big fat .mobi file that Kindle Previewer made for you and email it to your Kindle. (If you’ve never done this, your Kindle has an email address. You can find it in your Amazon account pages.) When Amazon delivers the file to you, it will have been converted to whatever kind of file your Kindle supports. If your Kindle is anything like recent that will be an .azw3 file. Now connect your Kindle to your computer with a USB cable, then open the Documents folder and find the version Amazon sent you. Copy that to your computer.

There you go. Now you can offer your readers both .mobi and .azw3 files for their Kindles, from your own web site, and those files won’t be any bigger than they need to be.

 
 

Leave a Reply

Your email address will not be published. Required fields are marked *

webomator
The Webomator Blog is powered by WordPress.
Down in the Basement. Where it Strains Against its Chains and Turns a Gigantic Wheel of Pain, for all Eternity. Muahahahahaha.