> For the complete documentation index, see [llms.txt](https://imgo.gitbook.io/cn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://imgo.gitbook.io/cn/api/tobase64.md).

# ToBase64

返回图像的 PNG 格式的 Base64 编码字符串。

## 参数

无

## 返回值

`string`

## 例子

```go
package main

import (
    "github.com/fishtailstudio/imgo"
)

func main() {
    base64Img := imgo.Load("gopher.png").ToBase64()
}
```

例子的 `base64Img` 字符串为 `data:image/png;base64,......`
