I have 3 separate *.tif image files as grayscale. They are representing data acquired with a scanner. Each of them is a separate band of the scanner; red, green, and blue. I would like to reassemble them in a single RGB *.tif image file.

Using gdal_merge.py -o RGB.tif -co PHOTOMETRIC=RGB red.tif green.tif blue.tif

doesn't work; I end up with a single grayscale image which size is the sum of all individual images. How to achieve this simple operation?

(They are not geotiff, just simple tif files; there is no tfw)


2 Answers 2


Per user30184's comment, you can use gdal_merge like so:

gdal_merge.py -separate  -o new_rgb.tif -co PHOTOMETRIC=RGB C:\input_r.tif C:\input_g.tif C:\input_b.tif

I had MemoryError with gdal_merge.py -separate ... when used on big input. Different answer helped my issue:

gdalbuildvrt -separate RGB.vrt red.tif green.tif blue.tif
gdal_translate RGB.vrt RGB.tif
  • +1. You should always use VRT's when possible. They're much less of a memory-hog. Dec 6, 2019 at 22:43
  • This was not the case for OP, but when merging GeoTiff files you may want to specify the CRS with e.g. -a_srs epsg:1234 to avoid further issues. Oct 8, 2020 at 13:03

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.