-
-
Notifications
You must be signed in to change notification settings - Fork 76
PFF format description
CHUNKSIZE = 256
HEADEROVERHEAD = 0x424
A pff file is composed of four parts :
- A header, containing general information about the file. Its size is 0x424.
- A table of JFIF image headers. One of this header has to be appended to the each tile to form a valid JPEG file.
- A table of pointers to the tiles contents.
- The tile contents.
Data | Offset in file (in bytes) | Size (in bytes) |
---|---|---|
Version | 0x8 | 4 |
Size of the JFIF image headers table | 0x74 | 4 |
Number of tiles | 0x7c | 4 |
width | 0x41c | 4 |
height | 0x420 | 4 |
The size of the header is fixed (0x424 bytes). It seems to be composed of three parts of size 904, 136, and 20.
I don't understand all the bytes in this header. There are many zeros.
Data | Offset in file (in bytes) | Size (in bytes) |
---|---|---|
Number of elements in the table | 0x424 | 4 |
Size of the first element | 0x428 | 4 |
First element contents | 0x42C | See previous line |
Size of the 2nd element | 0x42C + (size of the first element) | 4 |
Second element contents | ... | ... |
Data | Offset in file (in bytes) | Size (in bytes) |
---|---|---|
Offset in the file of tile number n
|
0x424 + (size of the JFIF table) + n * 8 |
8 |
Remark: the pointers are not aligned. They are all eight bytes long, but they may start at an offset that is not a multiple of 8.
This is just a region of the memory that contains the tiles data, glued together (no alignment). So the data of tile number n ends where the data of tile n+1 starts.
I don't know yet how to choose which JFIF header to prepend to which tile.
Tile number 0 is the topleft tile of the maximum zoom level (the level in which the image is the largest). Tiles are then numbered, in this order, from left to right, from top to bottom, from the highest zoom level to the lowest.
The ZoomifyServlet can take four arguments, passed as GET parameters:
-
file
: the path to the pff file -
vers
: pff file version number -
header
: the size of the JFIF headers table -
begin
: a beginning offset in the pff file (in bytes) -
end
: end offset -
requestType
: see below
It can be 0, 1 or 2.
Returns the metadata of the PFF file, in the following format:
Error=0&newSize=124&reply_data=<PFFHEADER WIDTH="7312" HEIGHT="5288" NUMTILES="839" NUMIMAGES="1" HEADERSIZE="16342" VERSION="106" ZA="0" TILESIZE="256" />
Returns a list of 64 bits integers from the file. Used to retrieve the pointers to tile data, but works for the whole file.
The answer is of the form:
Error=0&newSize=7557&begin=17402&end=24114&reply_data=31621, 0 6217 11886 17014 22687
In reply_data
, the first number (before the comma) is the 8-byte integer that starts at the offset begin
in the file. (where begin
is a get parameter that you passed).
The following numbers are the differences between the following 8-byte integers, and the first. That is, in the example above, there is a tile that starts at offset 31621 and ends at offset (31621+6217=37838), another that starts at offset (31621+6217) and ends at offset (31621+11886), etc...
In order to get the image, you can call
GET ZoomifyServlet?requestType=0&begin=31621&end=37838&file=...&head=1