JPEG2000 Profile

Kakadu compression parameters

Digital Bodleian uses a specific set of kdu_compress options (DEFAULT_LOSSLESS_COMPRESS_OPTIONS) for lossless JP2 conversion, and alters the rate and Creversible parameters for lossy JP2 conversion.

The terminal commands are as follows:

Lossless

kdu_compress -i input.tif -o output.jp2 Clevels=6 Clayers=6 “Cprecincts={256,256},{256,256},{128,128}” “Stiles={512,512}” Corder=RPCL ORGgen_plt=yes ORGtparts=R “Cblk={64,64}” Cuse_sop=yes Cuse_eph=yes -flush_period 1024 Creversible=yes -rate -

Lossy

kdu_compress -i input.tif -o output.jp2 Clevels=6 Clayers=6 “Cprecincts={256,256},{256,256},{128,128}” “Stiles={512,512}” Corder=RPCL ORGgen_plt=yes ORGtparts=R “Cblk={64,64}” Cuse_sop=yes Cuse_eph=yes -flush_period 1024 -rate 3

Parameter explanation

  • Clevels=6 Resolution levels. At least 3 are recommended to help compression. After that, the aim is to have the lowest resolution sub-image be roughly thumbnail-sized, so the optimal value is dependent on image size. 1

  • Clayers=6 Quality layers. More layers can help with quicker decompression; you can decode only a subset of the layers when dealing with lower resolution images where quality decrease is not noticed. 1

  • -rate - Compression rates for each quality layer. An initial value of - is needed to ensure true losslessness, as otherwise some data may be discarded. Subsequent numbers can be added to specify bit-rates for each of the lower quality layers - if they are all left unspecified, as they are here, “an internal heuristic determines a lower bound and logarithmically spaces the layer rates over the range” 2

  • Creversible=yes Use reversible wavelet and component transforms (required for losslessness) 1

  • Cprecincts={256,256},{256,256},{128,128} Precinct sizes for each resolution level. The last value applies to all subsequent levels 2

  • Stiles={512,512} Tile size 2

  • Corder=RPCL Progression order of Resolution, Position, Component, Layer. This defines which sub-images occur first in the datastream. Having resolution first optimises for fast decompression of thumbnails]. 1 Performance analysis by the British Library 4 recommended RPCL for their use case.

  • ORGgen_plt=yes Include packet length information in the header of all tile-parts 2

  • ORGtparts=R Controls the division of each tile’s packets into tile-parts 2

  • Cblk={64,64} Code-block size 2

  • Cuse_sop=yes Include SOP markers. Limits the damage of bit flipping errors to a single block 3

  • Cuse_eph=yes Include EPH markers. Limits the damage of bit flipping errors to a single block 3

  • -flush_period 1024 allows streaming when writing to output file. The value is dependent on tile size and sometimes precinct size 2

For RGBA images we add:

  • -jp2_alpha Treat the 4th image component as alpha 2

References

1(1,2,3,4)

JPEG 2000 as a Preservation and Access Format for the Wellcome Trust Digital Library

2(1,2,3,4,5,6,7,8)

kdu_compress -usage (online copy here)

3(1,2)

JPEG 2000 Specifications for The National Library of the Czech Republic

4

British Library JPEG 2000 profile

Note: most of these are from around 2010 - more recent examples of profiles would be welcome.