Opened 16 years ago
Closed 16 years ago
#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 |
---|---|---|---|
Priority: | normal | Milestone: | 1.5.4 |
Component: | GDAL_Raster | Version: | unspecified |
Severity: | normal | Keywords: | gtiff |
Cc: |
Description
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.
Attachments (1)
Change History (3)
by , 16 years ago
Attachment: | gdal.patch added |
---|
comment:1 by , 16 years ago
Component: | default → GDAL_Raster |
---|---|
Keywords: | gtiff added |
Milestone: | → 1.5.4 |
Status: | new → assigned |
I'll review and apply this.
comment:2 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I confirmed the problem using gdalwarp.
gdalwarp utm.tif out.tif -co COMPRESS=JPEG -co JPEG_QUALITY=10
I have applied the fix in trunk (r15657) and 1.5 branch (r15658).
The problem only impacted Create() related files, not CreateCopy() created files.
Patch to 1.5.3 version of GDAL to fix JPEQ and ZIP quality setting