Wednesday, March 26, 2008

Deep Zoom items.bin file decoded

Thanks to George Bell (check out the comment section on this Expression Team blog), I became aware of a undocumented command line tool, sparseimagetool.exe, that is bundled with the Deep Zoom composer. This is a nifty tool which can generate a collection given a simple xml file. This helps when one needs to process a large number of images. The xml file should be created along the lines of the SparseImageSceneGraph.xml that is output by the Deep Zoom composer.

Usage: SparseImageTool CreateCollection

While I was playing with this tool, I noticed a 'Use XML' format option. I tried it and it generated a items.xml file instead of a items.bin file. While this xml file cannot be used as input to the MultiScaleImage I thought it would be interesting to see if I could decode the items.bin file from this xml file. I don't know what I am going to achieve by decoding this file but it does bring up interesting possibilities; one possibility could be - to implement filtering by modifying the items.bin file itself instead of playing around with the Opacity of each MultiScaleSubImage. This might seem overkill but is worth investigating for a large collection!

This is what my sample items.xml file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<Collection Version="2" UseStringsFile="0" MinLevel="0" MaxLevel="8" PageSizeLog2="8" PageFormat="jpg" PageQuality="1" NextItemId="6" ItemCount="6">
<Thumbnails>
<Thumbnail Id="0" MinLevel="0" MaxLevel="8" SizeX="0.6953125" SizeY="0.521484375"/>
<Thumbnail Id="1" MinLevel="0" MaxLevel="8" SizeX="0.6953125" SizeY="0.521484375"/>
<Thumbnail Id="2" MinLevel="0" MaxLevel="8" SizeX="0.6953125" SizeY="0.521484375"/>
<Thumbnail Id="3" MinLevel="0" MaxLevel="8" SizeX="0.6953125" SizeY="0.521484375"/>
<Thumbnail Id="4" MinLevel="0" MaxLevel="8" SizeX="0.6953125" SizeY="0.521484375"/>
<Thumbnail Id="5" MinLevel="0" MaxLevel="8" SizeX="0.6953125" SizeY="0.521484375"/>
</Thumbnails>
<Items>
<Item Id="0" Init="test2_images\DSCF0067.sdi" Relative="1" Type="ImagePixelSource" Thumb="0"/>
<Item Id="1" Init="test2_images\DSCF0078.sdi" Relative="1" Type="ImagePixelSource" Thumb="1"/>
<Item Id="2" Init="test2_images\DSCF0082.sdi" Relative="1" Type="ImagePixelSource" Thumb="2"/>
<Item Id="3" Init="test2_images\DSCF0087.sdi" Relative="1" Type="ImagePixelSource" Thumb="3"/>
<Item Id="4" Init="test2_images\DSCF0090.sdi" Relative="1" Type="ImagePixelSource" Thumb="4"/>
<Item Id="5" Init="test2_images\DSCF0061.sdi" Relative="1" Type="ImagePixelSource" Thumb="5"/>
</Items>
</Collection>

I used the above XML file to decode the corresponding items.bin file

Bytes (Hex)

00 Version (2)
01-04 UseStringsFile (0)
05-08 MinLevel (0)
09-0C MaxLevel (8)
0D-10 PageSizeLog2 (8)
11-14 ?? - PageQuality? (1)
15-1C ?? - PageFormat? (jpg)
1D-20 NextItemId (6)
21-24 ItemCount (6)

Thumbnail information for 1 thumbnail (Repeat for each thumbnail)
25-28 Thumbnail Id (0)
29-2C MinLevel (0)
2D-30 MaxLevel (8)
31-34 SizeX (0.6953125)
35-38 SizeY (0.521484375)

Item information (Repeat for each item)
9D-A0 Item Id (0)
A0-A4 Init Length (24)
A4-BC Init (test2_images\DSCF0067.sdi)
BD Relative (1)
BE-C1 Type Length (16)
C2-D1 Type (ImagePixelSource)
D2-D5 Thumb (0)

1 comment:

Anonymous said...

Excellent work! Thanks for sharing