Retrieve True Color PNG image with digital numbers units: "DN"

I’m getting a white image when using units as digital numbers “DN”

How to get correct image when using units: “DN”?
I want to use units: “DN” because I want to get all raw bands GeoTIFF here is the evalscript:

//VERSION=3
function setup() {
  return {
    input: [{
      bands: ["B01", "B02", "B03", "B04", "B05", "B06", "B07", "B08", "B8A", "B09", "B11", "B12"],
      units: "DN"
    }],
    output: [
	{
      id: "True_Color",
      bands: 3,
      sampleType: "AUTO" // default  - scales the output values from input values [0,1] to [0,255].
	  }]
  }
}
function evaluatePixel(sample) {
    return {
		//  output band values are scaled from [0,1] to [0,255]. Multiply by 2.5 to increase brightness
		True_Color: [2.5*sample.B04, 2.5*sample.B03,  2.5*sample.B02]
	}
}

You will have to change this line to sampleType: "UINT16". And then return all the bands you are interested in directly.

See the documentation about more detailed info on sample types: Evalscript V3

Thanks @jonas.viehweger for your reply.

I changed the sampleType to "UINT16" but the returned image is darker than the real true color image. I manipulated the evaluatePixel() function and multiply by different values but the returned image each time is either darker or brighter than the true color image.

function evaluatePixel(samples) {
    return {
              True_Color: [2.5 * samples[0].B04, 2.5 *  samples[0].B03 , 2.5 *  samples[0].B02]
	}
}

result PNG when multiply by 2.5

function evaluatePixel(samples) {
    return {
		True_Color:  [samples[0].B04* 12,  samples[0].B03 * 12, samples[0].B02* 12]
	}
}

result PNG when multiply by 12

Expected true color PNG image with default units as ‘REFLECTANCE’ and sampleType: "AUTO" with evalscript :

//VERSION=3
function setup() {
  return {
    input: [{
      bands: ["B01", "B02", "B03", "B04", "B05", "B06", "B07", "B08", "B8A", "B09", "B11", "B12"],      
    }],
	mosaicking: Mosaicking.ORBIT,
    output: [
	{
      id: "True_Color",
      bands: 3,
      sampleType: "AUTO" 
	  }]
  }
}
function evaluatePixel(samples) {
    return {
		True_Color:  [ 2.5 * samples[0].B04, 2.5 * samples[0].B03 , 2.5* samples[0].B02]
	}
}

I’ve checked the documentation HOW ARE THE VALUES CALCULATED WITHIN SENTINEL HUB AND HOW ARE THEY RETURNED AS AN OUTPUT?
but I didn’t know what to use the right value to multiply by. Can you please help me fix this and get the correct PNG when using units: "DN"

Thank you.

Hi Hosam,

There is no right value to multiply by if you are doing this just for visualisation purposes. The value will depend on a wide variety of factors including the time of year and geolocation of the AOI. 2.5 generally works well in most places but it’s always worth experimenting too.

If trying to obtain reflectance for Sentinel-2 I recommend reading through this part of the docs explaining how to calculate this.

I am tossing a wild gues here, but I suspect the image with AUTO is first rescaled to min-max range of the tile statistics (or at least shifted to the 0) - and then it is multiplied by 2.5. I am also investigating this problem with the values inconsistency.