# Load

加载图像。

## 参数

<table><thead><tr><th width="198.4826833846656">参数名</th><th width="208.18338610093963">类型</th><th>说明</th></tr></thead><tbody><tr><td>source</td><td><code>interface{}</code></td><td>图像资源</td></tr></tbody></table>

`source` 参数支持以下类型：

<table><thead><tr><th width="236.7279029462738">支持类型</th><th>数据类型</th></tr></thead><tbody><tr><td>文件系统中图像的绝对路径或相对路径</td><td><code>string</code> 或 <code>[]byte</code></td></tr><tr><td>图片的 URL</td><td><code>string</code> 或 <code>[]byte</code></td></tr><tr><td>Base64 编码的图像数据</td><td><code>string</code> 或 <code>[]byte</code></td></tr><tr><td><code>*os.File</code> 类型的文件实例</td><td><code>*os.File</code></td></tr><tr><td>实现了 <code>image.Image</code> 接口的类型实例</td><td><code>image.Image</code> 以及实现了 <code>image.Image</code> 接口的类型</td></tr><tr><td><code>*imgo.Image</code> 类型的实例</td><td><code>*imgo.Image</code></td></tr></tbody></table>

## 返回值

`*imgo.Image` 类型的实例。

## 例子

### 图像文件路径

```go
package main

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

func main() {
    imgo.Load("gopher.png").
        Save("out.png")
}
```

### 图像 URL

```go
package main

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

func main() {
    url := "https://www.baidu.com/img/flexible/logo/pc/result.png"
    imgo.Load(url).
        Save("out.png")
}
```

### Base64 编码的图像数据

```go
package main

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

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

### `*os.File` 类型的文件实例

```go
package main

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

func main() {
    file, err := os.Open("gopher.png")
    if err != nil {
        panic(err)
    }
    defer file.Close()

    imgo.Load(file).
        Save("out.png")
}
```

### 实现了 `image.Image` 接口的类型实例

```go
package main

import (
    "github.com/fishtailstudio/imgo"
    "image/png"
    "os"
)

func main() {
    file, err := os.Open("gopher.png")
    if err != nil {
        panic(err)
    }
    defer file.Close()

    img, err := png.Decode(file)
    if err != nil {
        panic(err)
    }

    imgo.Load(img).
        Save("out.png")
}
```

### `*imgo.Image` 类型的实例

```go
package main

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

func main() {
    img := imgo.Load("gopher.png")
    imgo.Load(img).
        Save("out.png")
}
```
