Archive for January, 2010
* Cybook t4b Format Specification
Posted on January 13th, 2010 by John. Filed under hardware.
The new epub thumbnail files (.epub.thn) are what Bookeen calls t4b files. They are very similar to the older t2b thumbnail files they were using in earlier versions of the Cybook firmware. As the name suggests instead of using 2 bits to represent color values 4 bits are now used. This increases the number of colors from 4 to 16. In addition to the increased color range the t4b files now require a header of “t4bp” without the quotes.
The image’s dimensions are 96×144. The bits representing 0, 1, 2, 3… are written directly to the file. it is very similar to a pgm file in this regard. Each 4 bit sequence represents a pixel color. Only black, white and shades of gray are supported.
Every t4b file will have 13,824 pixels. The file size will always be 6,916 bytes. The formula to determine this is: (height x width x 2 bits per pixel) / 8 bits per byte. ((96 * 144 * 4) / 8 ) + 4 = 6,916. The + 4 is the header.
Following are two python scripts for converting an image to a t4b file and for converting a t4b file into a pgm image.
image2t4b.py
#!/usr/bin/env python
import sys, Image
REDUCE_MARKS = [16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240]
def reduce_color(c):
val = 0
for mark in REDUCE_MARKS:
if c > mark:
val += 1
else:
break
return val
def main():
if len(sys.argv) != 3:
raise Exception('Must have 2 arguments. %s input.image output.epub.thn' % sys.argv[0])
outf = open(sys.argv[2], 'wb')
im = Image.open(sys.argv[1]).convert("L")
im.thumbnail((96, 144))
newim = Image.new('L', (96, 144), 'white')
x,y = im.size
newim.paste(im, ((96-x)/2, (144-y)/2))
outf.write('t4bp')
px = []
for p in newim.getdata():
px.append(p)
if len(px) == 2:
byte_val = bin(reduce_color(px[0]))[2:].zfill(4) + bin(reduce_color(px[1]))[2:].zfill(4)
outf.write(chr(int(byte_val, 2)))
px = []
elif len(px) > 2:
raise Exception('Fatal error px length increased past 2.')
outf.close()
if __name__ == '__main__':
main()
t4b2pgm.py
#!/usr/bin/env python
import sys, os
def get_greys(b):
if not b:
return 0, 0
b = bin(int(ord(b)))
b = b[2:].zfill(8)
w = str(int(b[0:4], 2))
x = str(int(b[4:8], 2))
return w, x
def main():
if len(sys.argv) != 3:
raise Exception('Must have 2 arguments. %s input.epub.thm output.pgm' % sys.argv[0])
t4bfile = open(sys.argv[1], 'rb')
pgmfile = open(sys.argv[2], 'w')
pgmfile.write('P2\n96 144\n15\n')
# Read past the t4b header
t4bfile.read(4)
for i in range(144):
for j in range(48):
b = t4bfile.read(1)
vals = get_greys(b)
pgmfile.write('%s %s ' % (vals[0], vals[1]))
pgmfile.write('\n')
pgmfile.close()
t4bfile.close()
if __name__ == '__main__':
main()
* Cybook 2.0 Thumbnail Observations
Posted on January 13th, 2010 by John. Filed under hardware.
The 2.0 fimware for the Cybook and Opus have new thumbnails for epub files. They use the .thn extension and it is append after the .epub extension. This is unlike the _6090.t2b thumbnails which use the book name without the extension and _6090.t2b appended to it. I have yet to start figuring out this new format but at first glance it looks to be similar to the _6090.t2b files.
What I have found is, if a _6090.t2b file is present that will be used and the .thn file will not be generated and the _6090.t2b will be used as the thumbnail. However, if both the _6090.t2b and .thn are present then the .thn will be used.
* Beginner’s Guide to Calibre
Posted on January 13th, 2010 by John. Filed under articles.
* Calibre Week In Review
Posted on January 10th, 2010 by John. Filed under calibre.
Kovid just tagged the 0.6.33 release so it should be out the door later today. Only one major feature from me this week. The PRS driver can new customize what gets turned into a collection. The default was and is series and tags. Now under the device interface configuration you can specify any metadata field. The main use for this change is so people who have a large number of tags can disable collections being created from them.
While it’s not coming out today I have been working on a major feature. Metadata caching for devices. Basically a file that specifies all of the metadata for the books on the reader will be created. It will be used when the device is connected and if any files have changed their metadata will be updated. This speeds up device detection dramatically. Also, takes up less space than a book so it won’t use too much space to store it. Right now it’s storing the data using json so other application can have easy access to the data too. Other than faster device detection this is the ground work that is required to implement syncing.
* Cybook 2.0 Firmware Calibre Fix
Posted on January 9th, 2010 by John. Filed under calibre.
I’ve committed a fix for the Cybook 2.0 firmware id issue I posted yesterday. In calibre I’ve combined the Gen 3 and Opus device interfaces into one generic Cybook interface. Both were very similar and the Opus was just a subclass of the Gen 3. Also, with the 2.0 firmware being for both the Gen 3 and Opus there should be no difference in the capabilities of the two devices. If you own an Opus you will still want to use the Opus profile however, when you connect the device it will just show as using the Cybook interface. Also, with the interfaces being combined into one, the device specific configuration is now Cybook / Opus.
There were two reasons for combining the interfaces. I was unable to find a way to differentiate the Gen 3 and the Opus with the 2.0 firmware. A Gen 3 with the 2.0 firmware reports itself as an Opus. I was unable to find a way around this and felt it was better to have a Cybook interface. Also, I have the unfortunate pleasure of owning a Gen 3 which, even before the 2.0 firmware, used the same device ids of the Opus. It however did not use the Opus device strings. Due to this I am unable to determine if the 2.0 firmware changes the ids or just the strings. Combining the two interfaces keeps all Gen 3’s working and keeps some Gen 3’s from being detected as the Opus.
* Cybook 2.0 Firmware Identity Issues
Posted on January 7th, 2010 by John. Filed under calibre.
On Christmas eve Bookeen finally released the long awaited 2.0 firmware for the Cybook Gen 3 and Cybook Opus. As soon as I returned from my Christmas vacation I upgraded my Gen 3 to the 2.0 version. Today while debugging a device issue for calibre I noticed that my Gen 3 kept being detected as an Opus. Doing a little digging I found this:
$ calibre-debug -d Version: 0.6.32 USB devices on system: ... ['0xbda', '0x703', '0x110', 'Bookeen', 'Cybook Opus', '600AB038CB09484'], ... Looking for CYBOOKG3 (3034, 1795, 272, 'Bookeen', 'Cybook Opus', '600AB038CB09484') ... Looking for CYBOOK_OPUS (3034, 1795, 272, 'Bookeen', 'Cybook Opus', '600AB038CB09484') ... Devices possibly connected: Cybook Opus Device Interface, Trying to open Cybook Opus Device Interface ... OK Main memory: '/media/Cybook Gen3/' Total space: (495251456L, 0, 0)
It seems Bookeen has once again screwed up the firmware release. They wanted one firmware so now every Gen 3 that has updated now has the product identifier set to Opus. The Gen 3 models use a number of different hex product and vendor ids and only the later ones are the same as the opus. Anyone on Linux or OS X with an earlier Gen 3 who is using the 2.0 (possibly 1.5 but I didn’t test it) firmware will not have their device detected by calibre any longer. This is because once the hex ids are matched there is further matching based on the text ids for Linux and OS X. This isn’t going to be fun to work around.
* Teleread Article About Converting E-books
Posted on January 3rd, 2010 by John. Filed under Uncategorized.
* Calibre Week In Review
Posted on January 2nd, 2010 by John. Filed under calibre.
There was a major change this week to the device infrastructure. Kovid merged (with some modification) my changes to allow “Send to device” to use custom device paths just like “Save to disk”. Kovid’s major change to my implementation are having a separate save template for “Send to device” and allowing for per device overrides of the template. Kovid and I spent yesterday testing and it is working well. Expect it in the next release. Oh, News and the / tags still work as expected.
I did a little bit of work on TXT and PML output. Now they both honor the “Remove spacing between paragraphs” option. Previously TXT output had TXT specific options for this behavior. I’ve removed them and just use that look and feel option. PML output previously ignored it but now it honors it. So you can have both look more like a printed book than a web page.
Tags
Archives
- March 2010 (1)
- January 2010 (8)
- December 2009 (5)
- November 2009 (6)
- October 2009 (4)
- September 2009 (2)
- August 2009 (6)
- July 2009 (6)
- June 2009 (4)
- May 2009 (6)
- April 2009 (4)
- March 2009 (2)
- February 2009 (4)
- January 2009 (4)
- December 2008 (7)
- November 2008 (2)