[Gdal-dev] Help: 12bit JPEG compressed TIFF

Andrey Kiselev dron at ak4719.spb.edu
Wed Apr 28 02:24:02 EDT 2004

On Wed, Apr 28, 2004 at 09:46:09AM +0800, xqcheng wrote:
>  I have some tiff files compressed in JPEG, But cannot open.. The
>  error message is "cannot support 12 bits/sample". I want to know how
>  to solve this? Does it need modification to JPEG library.

Yes, libjpeg should be recompiled. There is extract from the JPEG
library documentation:

Support for 12-bit-deep pixel data:

The JPEG standard allows either 8-bit or 12-bit data precision.  (For color,
this means 8 or 12 bits per channel, of course.)  If you need to work with
deeper than 8-bit data, you can compile the IJG code for 12-bit operation.
To do so:
  1. In jmorecfg.h, define BITS_IN_JSAMPLE as 12 rather than 8.
  2. In jconfig.h, undefine BMP_SUPPORTED, RLE_SUPPORTED, and TARGA_SUPPORTED,
     because the code for those formats doesn't handle 12-bit data and won't
     even compile.  (The PPM code does work, as explained below.  The GIF
     code works too; it scales 8-bit GIF data to and from 12-bit depth
  3. Compile.  Don't expect "make test" to pass, since the supplied test
     files are for 8-bit data.

Currently, 12-bit support does not work on 16-bit-int machines.

Note that a 12-bit version will not read 8-bit JPEG files, nor vice versa;
so you'll want to keep around a regular 8-bit compilation as well.
(Run-time selection of data depth, to allow a single copy that does both,
is possible but would probably slow things down considerably; it's very low
on our to-do list.)

Andrey V. Kiselev
Home phone:  +7 812 5274898  ICQ# 26871517

More information about the Gdal-dev mailing list