I have to save /Export raster layer to image . How this can be done using Python Script .

I can do this with GDAL script but this creates an image with low resolution

 gdal_translate -of GTiff abc.tif out.jpeg


 gdal_translate -of JPEG -B 1 -B 2 -B 3 abc.tif out.jpeg

Is there any way to preserve the resolution while creating image using GDAL ?

  • gdal_translate -of GTiff abc.tif out.jpeg will output a GeoTiff called out.jpeg. It won't actually be JPEG format.
    – user2856
    Dec 6, 2016 at 22:23

1 Answer 1


What you are showing shouldn't be changing the resolution of the image in terms of the georeferencing, but is actually compressing the image.

You can set the level of compression using a creation option called QUALITY (GDAL jpeg docs).

gdal_translate -of JPEG -co "QUALITY=95" abc.tif out.jpeg
  • i tried it but shows Input File size is 219,163 0Error 6 :JPEG Driver doesn't support 2 bands. Must be 1 (grey) ,3 (RGB) ,or 4 Bands.
    – User18
    Dec 7, 2016 at 4:45
  • 1
    Due to jpeg's specs, it will need 1, 3, or 4 bands. Either duplicate one of the input bands into another channel or save as two separate raster files. (gdal_translate docs) GeoTiffs don't have this requirement, so consider using that format if it is acceptable within the workflow. Dec 7, 2016 at 5:01

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.