Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question
1  
what do you see when you run gdal_info on the file? –  johanvdw Jun 3 '12 at 11:26
add comment

3 Answers

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

Nick.

share|improve this answer
    
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
show 4 more comments

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

Usage:

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...

share|improve this answer
add comment

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
share|improve this answer
    
no, i need to convert from tiff to jpg/jpeg –  Enamul Haque Jun 2 '12 at 14:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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