> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wherobots.com/llms.txt
> Use this file to discover all available pages before exploring further.

# RS_AsPNG

Returns a PNG byte array, that can be written to raster files as PNGs using the Sedona raster writer. This function can only accept pixel data type of unsigned integer. PNG can accept 1 or 3 bands of data from the raster, refer to [RS\_Band](/reference/wherobots-db/raster-data/band-accessors/RS_Band) for more details.

<Note>
  Raster having `UNSIGNED_8BITS` pixel data type will have range of `0 - 255`, whereas rasters having `UNSIGNED_16BITS` pixel data type will have range of `0 - 65535`. If provided pixel value is greater than either `255` for `UNSIGNED_8BITS` or `65535` for `UNSIGNED_16BITS`, then the extra bit will be truncated.
</Note>

<Note>
  Raster that have float or double values will result in an empty byte array. PNG only accepts Integer values, if you want to write your raster to an image file, please refer to [RS\_AsGeoTiff](/reference/wherobots-db/raster-data/output/RS_AsGeoTiff).
</Note>

## Signatures

```sql theme={"system"}
RS_AsPNG(raster: Raster)
```

```sql theme={"system"}
RS_AsPNG(raster: Raster, maxWidth: Integer)
```

## Parameters

<ParamField body="raster" type="Raster" required>
  The input raster.
</ParamField>

<ParamField body="maxWidth" type="Integer">
  The maximum width of the output PNG.
</ParamField>

## Return type

<ResponseField type="Binary">
  The raster as a PNG byte array.
</ResponseField>

## Examples

```sql theme={"system"}
SELECT RS_AsPNG(raster) FROM Rasters
```

```
[-119, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73...]
```

### With band reordering

```sql theme={"system"}
SELECT RS_AsPNG(RS_Band(raster, Array(3, 1, 2)))
```

```
[-103, 78, 94, -26, 61, -16, -91, -103, -65, -116...]
```
