2006.06.24 17:42 "[Tiff] GEOKEYDIRECTORY & JPEG Support", by oded orbach

hello,

I'm writing a code for copying a TIFF file from an input file to an output file.

all going well except for two problems:

1. I'm having some problems with the GEOKEYDIRECTORY tag (I'm supporting GEOTIFF as well..).

here is a part of my code:
int clone(const char* pIn, const char* pOut)
{
tiff* pInTiff = XTIFFOpen(pIn, "r");
tiff* pOutTiff = XTIFFOpen(pOut, "r");

  GTIF * geoTiffSrc = GTIFNew(PInTiff);
  GTIF * geoTiffDest = GTIFNew(POutTiff);

unsigned short * keyDirectory;
geocode_t shortVal;
unsigned short Aux;
shortVal = 0;
GTIFKeyGet(geoTiffSrc, (geokey_t)GTModelTypeGeoKey,&shortVal,0,1);
if (shortVal!=0) GTIFKeySet(geoTiffDest, (geokey_t)GTModelTypeGeoKey, TYPE_SHORT, 1, shortVal);
// and so on with many other goekey tags...
if (TIFFGetField(pInTiff, TIFFTAG_GEOKEYDIRECTORY, &Aux, &keyDirectory))
    TIFFSetField(pOutTiff, TIFFTAG_GEOKEYDIRECTORY, Aux, keyDirectory);
//and so on with many other tags...
}

I used GTIFKeyGet for many GEOTIFF tags, and TIFFGetField for many TIFF tags. when I tried to use only TIFFGetField, I've had problems with reading the GEOTIFF tags. one example of a file where everything goes well including this tag:

GEOKEYDIRECTORY = {1, 1, 0, 2, 1024, 0, 1, 0, 2048, 0, 1, 0} (for both input and output file).

one example of a file where everything goes well except for this tag:

GEOKEYDIRECTORY = {1, 1, 0, 2, 1024, 0, 1, 32767, 2048, 0, 1, 0} (input file).

GEOKEYDIRECTORY = {1, 1, 0, 1, 1024, 0, 1, 32767} (output file).

meaning that the tag number 2048 (GeographicTypeGeoKey) for some reason was not copied successfully, and so is the GEOKEYDIRECTORY tag.

I have no idea what to do about it.

2. my application does not support JPEG compression. whenever a TIFF file with a JPEG compression is inserted as an input to my application, when I reach the call to TIFFReadTile (in order to read tiles from the input file and copy the image), windows shows a message: JPEG compression support is not configured. the value of the TIFFTAG_COMPRESSION in this case is 7 (COMPRESSION_JPEG).

I'm trying to add a command at the beginning of the code:

#define JPEG_SUPPORT

or add also before that command another one:
#define COMPRESSION_SUPPORT

but it won't help.

what should I do in order to be able to support JPEG compression TIFF files?

thanks in advance and sorry for the long mail...

---------------------------------
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1¢/min.