Ticket #2642 (closed defect: fixed)
JPEG quality for GeoTiff is always set to 75, and zip quality is always the default value
|Reported by:||smyth||Owned by:||warmerdam|
I have a program that creates a raster file using the the gtiff driver. I have set the jpeg quality using the option string "JPEQ_QUALITY=<value>". When I run the program first with a quality of 10, and then with a quality of 90 I get identical output - the quality has no effect. My guess was that the JPEQ quality gets set to the default 75 each time.
I ran my program in a debugger using a debug version of GDAL version 1.5.3 (using the --enable-debug option).
Going through the debugger, it looks like the quality is initially set correctly. However, before the first write a call is made to GTiffDataset::Crystalize. In the GTiffDataset::Crystalize() function, the routine TIFFSetDirectory is called. A side effect of calling this function is that the compression is reinitialized, setting the quality back to the the default of 75. This reset value is then what is used when the writing occurs.
I have a patch to fix this, which I've attached. This patch is similar to what is already done in GTiffCreateCopy, where the tags for the zip and JPEG quality get reset after closing and opening the file. The patch just grabs the zip and jpeg quality tags at the beginning of Cystalize routine and then reset them at the end of the routine.