I am using gdal_translate -of JPEG -scale -co worldfile=yes ndvi.tiff output.jpg command to convert tiff images to jpg and resize it. But it generates only black and white images.

How can I generate colorful images when converting from tiff to jpg/jpeg?

  • 1
    what do you see when you run gdal_info on the file? – johanvdw Jun 3 '12 at 11:26

I think you'll find you need to add -expand rgb to your command line, for example:

gdal_translate -expand rgb -of JPEG input.tif output.jpg -co WORLDFILE=YES


  • I tried your given commmand. but it does not provide any uutput rather shows "Option -expand incomplete, or not recognised" how to overcome this problem? – Enamul Haque Jun 2 '12 at 11:36
  • This is strange, it works here. If you copied the command line from here and pasted it into a command window there might be a font encoding problem. Try typing the command line rather than copying and pasting. Nick. – nhopton Jun 2 '12 at 13:21
  • i typed it but yet no luck for me. is there any other reason or do i need to install some packages or so? – Enamul Haque Jun 2 '12 at 14:12
  • Okay, try running gdal_translate from within QGIS (Raster -> Conversion -> Translate). Tick 'Expand' and select 'RGB'. I can't understand why this isn't working from the command line, most odd. Nick. – nhopton Jun 2 '12 at 16:48
  • i run the next commadn "gdal_translate -expand rgb -of JPEG -scale -co worldfile=yes ndvi.tiff output.jpg" and it gives Input file size is 4087, 2176 Error : band 1 has no color table any suggestion – Enamul Haque Jun 2 '12 at 16:53

you should use pct2rgb.py script for converting an 8bit paletted image to 24bit RGB.


pct2rgb.py [-of format] [-b band] [-rgba] source_file dest_file

you can find script here. and some information here.

i hope it helps you...


Resize images with GDAL? Did you try to convert TIFF to ECW?

gdal_translate -of ECW -co TARGET=0 -expand rgb -a_srs EPSG:4326 input.tif output.ecw
  • no, i need to convert from tiff to jpg/jpeg – Enamul Haque Jun 2 '12 at 14:14

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.