capture

package module
v0.0.0-...-2f84c12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2020 License: MIT Imports: 15 Imported by: 0

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Captcha

type Captcha struct {
	Code  []byte
	Image []byte
	// contains filtered or unexported fields
}

Captcha use Code and Image for your business

func New

func New(attributes ...*attribute.Attributes) (capture *Captcha, err error)

New create a new Capture object

func (*Captcha) Reload

func (c *Captcha) Reload() (err error)

Reload refresh Code and Image

func (*Captcha) String

func (c *Captcha) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL