> ## 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_AsBase64

Returns a base64 encoded string of the given raster. If the datatype is integral then this function internally takes the first 4 bands as RGBA, and converts them to the PNG format, finally produces a base64 string. When the datatype is not integral, the function converts the raster to TIFF format, and then generates a base64 string. To visualize other bands, please use it together with `RS_Band`. You can take the resulting base64 string in [an online viewer](https://base64-viewer.onrender.com/) to check how the image looks like.

<Note>
  This function only works for rasters with byte data, and bands ≤ 4 (Grayscale - RGBA). You can check the data type of an existing raster by using [RS\_BandPixelType](/reference/wherobots-db/raster-data/band-accessors/RS_BandPixelType) or create your own raster by passing `'B'` while using [RS\_MakeEmptyRaster](/reference/wherobots-db/raster-data/constructors/RS_MakeEmptyRaster).
</Note>

<Warning>
  This is not recommended for large files.
</Warning>

## Signatures

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

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

## Parameters

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

<ParamField body="maxWidth" type="Integer">
  The max width value.
</ParamField>

## Return type

<ResponseField type="String">
  A string representation.
</ResponseField>

## Example

```sql theme={"system"}
SELECT RS_AsBase64(raster) from rasters
```

```
iVBORw0KGgoAAAA...
```
