Insert
Last updated
Last updated
inserts a image into the current image.
source
interface{}
image to be inserted
x
int
X-Coordinate of the top-left corner of source
.
y
int
Y-Coordinate of the top-left corner of source
.
source
parameters support the following types:
Path of the image in filesystem.
string
或 []byte
URL of an image.
string
或 []byte
Base64 encoded image data.
string
或 []byte
The instance of *os.File
.
*os.File
The instance of the types that implement the image.Image
interface.
image.Image
and the types that implement the image.Image
interface.
The instance of *imgo.Image
.
package main
import (
"github.com/fishtailstudio/imgo"
"image/color"
)
func main() {
imgo.Canvas(500, 500, color.Black).
Insert("gopher.png", 100, 100).
Save("out.png")
}
package main
import (
"github.com/fishtailstudio/imgo"
"image/color"
)
func main() {
url := "https://www.baidu.com/img/flexible/logo/pc/result.png"
imgo.Canvas(500, 500, color.Black).
Insert(url, 100, 100).
Save("out.png")
}
package main
import (
"github.com/fishtailstudio/imgo"
"image/color"
)
func main() {
base64Img := imgo.Load("gopher.png").ToBase64()
imgo.Canvas(500, 500, color.Black).
Insert(base64Img, 50, 50).
Save("out.png")
}
*os.File
package main
import (
"github.com/fishtailstudio/imgo"
"image/color"
"os"
)
func main() {
file, err := os.Open("gopher.png")
if err != nil {
panic(err)
}
defer file.Close()
imgo.Canvas(500, 500, color.Black).
Insert(file, 100, 100).
Save("out.png")
}
image.Image
interfacepackage main
import (
"github.com/fishtailstudio/imgo"
"image/color"
"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.Canvas(500, 500, color.Black).
Insert(img, 100, 100).
Save("out.png")
}
*imgo.Image
package main
import (
"github.com/fishtailstudio/imgo"
"image/color"
)
func main() {
img := imgo.Load("gopher.png")
imgo.Canvas(500, 500, color.Black).
Insert(img, 100, 100).
Save("out.png")
}
The instance of *imgo.Image
.
*imgo.Image