I am facing difficulty converting between Sentinel GeoTIFF file and JPEG file. I used below command i.e.

gdal_translate -b 4 -b 3 -b 2 -of JPEG -scale inputimage.tif outputfile.jpeg

The problem with this approach is, that if I convert 32*32 TIFF file into JPEG and if the same patch is from 1000*1000 TIFF file and I convert that file into JPEG, then in both cases the same patch looks different in both JPEG files.

1 Answer 1


From the documentation:

-scale [src_min src_max [dst_min dst_max]]:

Rescale the input pixels values from the range src_min to src_max to the range dst_min to dst_max. If omitted the output range is 0 to 255. If omitted the input range is automatically computed from the source data.

The smaller patch will have different min and max values (input range). If you want the smaller patch to look the same same as the larger (or vice-versa) pass the appropriate range(s) to the -scale parameter. For example (with totally made up min/max values, you'll need to change these to something appropriate for your data):

gdal_translate -b 4 -b 3 -b 2 -of JPEG -scale 0 1234 0 2345 0 4567 inputimage.tif outputfile.jpeg
  • Got it . According to you what should be the ideal min max value that should work across all geotiff ?
    – bambi
    Mar 27, 2019 at 21:50
  • I can't say, it completely depends on your data.
    – user2856
    Mar 27, 2019 at 22:09

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.