Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Formats > Kindle Formats

Notices

Reply
 
Thread Tools Search this Thread
Old 12-01-2011, 02:42 PM   #1
rodrigoccurvo
Member
rodrigoccurvo began at the beginning.
 
Posts: 13
Karma: 10
Join Date: May 2011
Location: Campo Grande, MS, Brazil
Device: Kindle 3
Lightbulb Correct Mobi location formula (maybe)

Hi, everyone.

For a while I've been trying to understand Kindle's location and the consensus seems to be that for Mobi 1 location = 128 bytes (it's even on http://wiki.mobileread.com/wiki/Page_numbers).

But today I was taking a look at the Amazon Cloud Reader (reader.amazon.com) source code and I found the following:

Code:
locationFromPosition: function (a) {
        return Math.floor(a * 2 / 300 + 1)
}
(The file is KindleReaderApp-min.js, but I won't post the whole link since it's weird and I don't know if it has session informations. I guess you can find it on your own.)

The surrounding code is a bit larger, but in the end that seems to be the formula used for calculating the location for the Mobi format (there is another for topaz which is Math.floor((a * d + 100) / 100)).

I've tried looking at the parameter "a" and for the text parts it seems to be characters, but I don't know if that means bytes for every case. I've tested it a little bit just to know if it's correct and it seems to be, but not enough for me to be sure. Also, I don't know if the relation holds for images and other things apart from characters.

I don't know and couldn't find the original source for the 128 bytes information, so I'm guessing it's an approximation. But as I said, in my initial tests the above formula seems to work.

What to you guys think? Does it make sense? Is the 128 bytes info an approximation or is it on the format specs?

[]'s

Rodrigo
rodrigoccurvo is offline   Reply With Quote
Old 12-01-2011, 04:03 PM   #2
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 8,665
Karma: 38766103
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I've always heard 128 bytes of source html, but since Amazon doesn't release detailed specs, who knows?
DiapDealer is online now   Reply With Quote
 
Enthusiast
Old 12-01-2011, 04:25 PM   #3
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: 30,660
Karma: 85135660
Join Date: Jul 2007
Location: Norfolk, England
Device: NOOK ST GlowLight
Quote:
Originally Posted by rodrigoccurvo View Post
Hi, everyone.

For a while I've been trying to understand Kindle's location and the consensus seems to be that for Mobi 1 location = 128 bytes (it's even on http://wiki.mobileread.com/wiki/Page_numbers).

But today I was taking a look at the Amazon Cloud Reader (reader.amazon.com) source code and I found the following:

Code:
locationFromPosition: function (a) {
        return Math.floor(a * 2 / 300 + 1)
}
(The file is KindleReaderApp-min.js, but I won't post the whole link since it's weird and I don't know if it has session informations. I guess you can find it on your own.)

The surrounding code is a bit larger, but in the end that seems to be the formula used for calculating the location for the Mobi format (there is another for topaz which is Math.floor((a * d + 100) / 100)).

I've tried looking at the parameter "a" and for the text parts it seems to be characters, but I don't know if that means bytes for every case. I've tested it a little bit just to know if it's correct and it seems to be, but not enough for me to be sure. Also, I don't know if the relation holds for images and other things apart from characters.

I don't know and couldn't find the original source for the 128 bytes information, so I'm guessing it's an approximation. But as I said, in my initial tests the above formula seems to work.

What to you guys think? Does it make sense? Is the 128 bytes info an approximation or is it on the format specs?

[]'s

Rodrigo
Now, that's an interesting finding. And it can be checked fairly easily. My copy of The Lord of the Rings in Kindle for Mac has 24992 locations. The raw mobi-html is 3748684 bytes long. Plugging that into the forumla you've found, you get 24992 (.22666...). Taking the 128 bytes estimate, you get 29286 (.59375).

My LotR is encoded with Windows Latin-1. Let's see what happens with a UTF-8 encoded ebook. I suspect that we need to pass bytes, not characters.

My copy of Unfinished Tales is a (kindlegen compiled) conversion from an ePub. It's utf-8 encoded. It has 1590431 characters, but 1613151 bytes of mobi-html. In Kindle for Mac it has 10755 locations.

1590431*2/300+1 =10603 (.87333...)
1613151*2/300+1 =10755 (.34)

Well. That seems definite. The number of bytes (not characters) through the unpacked mobi-html of the book, when divided by 150, adding 1 and truncating, is the kindle location in the book.

Good find!
pdurrant is offline   Reply With Quote
Old 12-01-2011, 04:30 PM   #4
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: 30,660
Karma: 85135660
Join Date: Jul 2007
Location: Norfolk, England
Device: NOOK ST GlowLight
I've updated that page in the wiki to reflect this new finding.
pdurrant is offline   Reply With Quote
Reply

Tags
kindle, location, mobi

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Patch: Use real ASIN instead of UUID in mobi files to show correct cover in KindleApp siebert Calibre 4 02-24-2012 08:13 AM
Does Calibre automatically converty PDF to .mobi to correct dimension ? bbs7772004 Devices 1 10-26-2011 07:59 PM
Calibre and mobi format - creating a paige or location specific table of contents coaver Conversion 2 01-25-2011 05:22 AM
Mobi to Kindle with correct metadata? rex0810 Calibre 3 09-25-2009 05:36 PM
Correct missing author info in a Mobi file? nekokami Kindle Formats 5 12-15-2008 10:26 AM


All times are GMT -4. The time now is 08:22 PM.


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