[gdal-dev] Return codes in gdalwarp

Michal Migurski mike at stamen.com
Fri Nov 13 02:28:23 EST 2009


Hello,

I think this is a bug report, or maybe a feature request.

I'm writing a script that shells out to gdalwarp. The GTiff files that  
I might see as input to this script include palette and non-palette  
images, and I'd like to be able to reliably compress the output  
without human intervention.

Initially, I tried -co COMPRESS=JPEG on everything in the hopes that  
gdalwarp would perform the necessary internal conversions to beat the  
output into a JPEG. This didn't work with palette images, for which I  
got an error like: "ERROR 1: JPEGSetupEncode:PhotometricInterpretation  
3 not allowed for JPEG"

Then I tried setting up a loop that tries JPEG first followed by LZW,  
but here I ran into difficulty recognizing a failure. The return code  
for the palette images with all the errors is still 0, just like the  
return code for a successful warp. The destination image is also  
populated, so it's not possible to check for existence to determine  
success.

What I'd love to see is a modification to the command-line behavior of  
gdalwarp so it can be better used in a scripted setting, where  
automated ways of detecting failure that don't require reading the  
error output strings would be incredibly helpful. Ideally, choosing an  
incompatible creation option would cause a non-zero exit and wouldn't  
create the destination file.

-mike.

----------------------------------------------------------------
michal migurski- mike at stamen.com
                  415.558.1610





More information about the gdal-dev mailing list