capture
a simple capture implementation
一个简易的图片验证码实现
Usage
package main
import (
"os"
"fmt"
"image/color"
"github.com/RedAFD/capture"
"github.com/RedAFD/capture/attribute"
"github.com/RedAFD/capture/wrapper"
)
func main() {
// create a new capture
c, err := capture.New()
if err != nil {
os.Exit(-1)
}
fmt.Println(c) // you can print capture data like this
// you can reload the capture object like this
err = c.Reload()
if err != nil {
os.Exit(-1)
}
// or you can create a custom capture
c, err = capture.New(&attribute.Attributes{
Width: 176,
Height: 72,
FontFile: "/user/local/share/xxx.ttf",
FontSize: 50,
FontHandler: nil, // not necessary, it will automatically generated by FontFile
CharCount: 4,
CharColor: color.RGBA{0x00, 0x00, 0x00, 0xff},
BackGroundColor: color.RGBA{0xff, 0xff, 0xff, 0xff},
Wrapper: wrapper.DefaultWrapper, // or you can write your own wrapper
})
if err != nil {
os.Exit(-1)
}
}