# Load

Load an image。

## Parameters

<table><thead><tr><th width="198.4826833846656">Parameter</th><th width="208.18338610093963">Type</th><th>Description</th></tr></thead><tbody><tr><td>source</td><td><code>interface{}</code></td><td>Image resource.</td></tr></tbody></table>

`source` parameters support the following types:

<table><thead><tr><th width="236.7279029462738">Support type</th><th>Data type</th></tr></thead><tbody><tr><td>Path of the image in filesystem.</td><td><code>string</code> 或 <code>[]byte</code></td></tr><tr><td>URL of an image.</td><td><code>string</code> 或 <code>[]byte</code></td></tr><tr><td>Base64 encoded image data.</td><td><code>string</code> 或 <code>[]byte</code></td></tr><tr><td>The instance of <code>*os.File</code> .</td><td><code>*os.File</code></td></tr><tr><td>The instance of the types that implement the <code>image.Image</code> interface.</td><td><code>image.Image</code> and the types that implement the <code>image.Image</code> interface.</td></tr><tr><td>The instance of <code>*imgo.Image</code> .</td><td><code>*imgo.Image</code></td></tr></tbody></table>

## Return Values

The instance of `*imgo.Image` .

## Examples

### Image Filepath

```go
package main

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

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

### Image 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 encoded image data

```go
package main

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

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

### The instance of `*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")
}
```

### The instance of the types that implement the `image.Image` interface

```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")
}
```

### The instance of `*imgo.Image`

```go
package main

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

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