I have an uncompressed GeoTIFF file (figure 1) with the following band information:

Image Structure Metadata:
Band 1 Block=5000x1 Type=Byte, ColorInterp=Red
Band 2 Block=5000x1 Type=Byte, ColorInterp=Green
Band 3 Block=5000x1 Type=Byte, ColorInterp=Blue
Band 4 Block=5000x1 Type=Byte, ColorInterp=Undefined

Original RGB image
Figure 1

I have compressed the file using the following set of parameters:

gdal_translate -of gtiff -co compress=jpeg -co jpeg_quality=85 -co tiled=yes -co photometric=rgb uncompressed.tif compressed.tif

This gives me a file with the following information:

Image Structure Metadata:
Band 1 Block=256x256 Type=Byte, ColorInterp=Red
Band 2 Block=256x256 Type=Byte, ColorInterp=Green
Band 3 Block=256x256 Type=Byte, ColorInterp=Blue
Band 4 Block=256x256 Type=Byte, ColorInterp=Undefined

When I serve my compressed image through GeoServer 2.1.4 I get image in figure 2 instead of the image in figure 1, which is what I would like. My goal is to have GeoServer just display the first three bands as RGB and ignore the 4th band.

4 band image in GeoServer 2.1.4
Figure 2

I have tried to style the raster layer in GeoServer using SLD by adding the following channel configuration, but it didn't help.


Why is my image server through GeoServer 2.1.4 looking the way it is and how do I configure GeoServer to display the image 'correctly'?


I don't know how GDAL handles JPEG compression on a four band raster, it does not make much sense to me, JPEG is meant to be used against RGB (three band) or gray (one band) images. When you gdal_translate it you can also shave off the fourth band with, I believe, -b 1 -b 2 -b 3

  • I guess you're right about JPEG and the number of bands. I had hoped to avoid doing any alterations to the original data set nor creating a specialised set just for GeoServer. But a 3-band data set is probably the way to go. Interesting though how GDAL handles multi-band JPEG compressed GeoTIFFs. Thanks for your answer!
    – Chau
    Jun 7 '12 at 12:52
  • 1
    I also don't know how gdal handles JPEG compression but I would try to use interleave=band instead of the default interleave=pixel and a recent version of GDAL (1.9 at least).
    – user12040
    Oct 17 '12 at 11:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.