Skip to content

Zoomify PFF file format documentation

Ophir LOJKINE edited this page Nov 15, 2020 · 6 revisions

File format description

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.

All numbers are stored in big endian.

Header

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.

JFIF image headers table

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 ... ...

Table of pointers

Data Offset in file (in bytes) Size (in bytes)
Offset in the file of tile number n+1 0x424 + (size of the JFIF table) + n * 8 8

The offset of the first tile (tile n°0) is 0x424 + (size of the JFIF table) + 8*numTiles: it is located right after the table of pointers.

We can see this table as a table of pointer to the end of each tile data, which is useful, because the tile metadata are located at the end of each tile.

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.

Tiles data

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.

Each tile data ends with the following 24-bytes footer:

Data Size (in bytes)
Length of footer (always ==0x18) 4
Unknown (image number, in the case of multiple images?) 4
Zoom level 4
Tile number inside level 4
size of the tile contents body in bytes 4
index of the JFIF header to use 4

some files seem to have a different 4-bytes footer that contains only the header index :

Data Size (in bytes)
index of the JFIF header to use 4

Tiles numbering

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.

Servlet API description

The ZoomifyServlet can take four arguments, passed as GET parameters:

  • file : the path to the pff file
  • vers : pff file version number
  • head : the size of the JFIF headers table
  • begin : a beginning offset in the pff file (in bytes)
  • end : end offset
  • requestType: see below

The requestType parameter

It can be 0, 1 or 2.

requestType = 1

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" />

requestType = 2

Returns a list of 64 bits integers from the file. Used to retrieve 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

requestType = 0

Returns a tile, with the right header prepended.

Examples

Files

Here are some example pff files:

Code

  • A parser for the file format itself in C: pff-extract.c
  • An image downloader that acts as a client to the servlet API in javascript: zoomify-pff.js
  • An image downloader for the servlet API in rust: pff.rs