3

I wanted to reduce the number of bands of a tif file from 3 to 1...

I used this command

rgb2pct.py -n 256 fnp_braunschweig.tif fnp_bs.tif

and it increased the size from 31mb to 778mb

I actually want to decrease the size of the file.

Why is this happening?

1 Answer 1

6

The output Tiff is likely not using compression, hence the larger file size. Use the gdal_translate command, something along the lines of this:

gdal_translate -of GTiff -co "COMPRESS=DEFLATE" -b N fnp_braunschweig.tif fnp_bs.tif

where N is the band number you want to keep. The options for compression are NONE, LZW, PACKBITS, JPEG, CCITTRLE, CCITTFAX3, CCITTFAX4, DEFLATE.

2
  • 1
    Especially note the -co "COMPRESS=DEFLATE" and -co "PHOTOMETRIC=YCBCR" if appropriate. Use gdalinfo to determine what the compression settings of the original tiff were and use creation options from gdal.org/frmt_gtiff.html appropriately. Commented Feb 23, 2012 at 14:05
  • thanks. how can I compress three bands into one? I don´t want to pick either red,green, or blue, I just want to compress them into one. Commented Feb 23, 2012 at 21:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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