Skip to content

wenlng/go-captcha-assets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang Assets File Of GoCaptcha

Go Captcha presets some default embedded resources and stores them in the Go file format. In addition, you can also configure the captcha according to your own needs.

Source Resources File: https://github.com/wenlng/go-captcha-resources

Install

$ go get -u github.com/wenlng/go-captcha-assets@latest

Use Assets

Chinese Text Assets

import "github.com/wenlng/go-captcha-assets/bindata/chars"

func Demo() {
    chars := chars.GetChineseChars()
}

Alpha Text Assets

import "github.com/wenlng/go-captcha-assets/bindata/chars"

func Demo() {
    chars := chars.GetAlphaChars()
}

Alpha Mixin Text Assets

import "github.com/wenlng/go-captcha-assets/bindata/chars"

func Demo() {
    chars := chars.GetMixinAlphaChars()
}

Font Assets

import "github.com/wenlng/go-captcha-assets/resources/fonts/fzshengsksjw"

func Demo() {
    fonts, err := fzshengsksjw.GetFont()
    if err != nil {
        log.Fatalln(err)
    }
}

Image Assets

//import "github.com/wenlng/go-captcha-assets/resources/images"
import "github.com/wenlng/go-captcha-assets/resources/imagesv2"

func Demo() {
    imgs, err := imagesv2.GetImages()
    if err != nil {
        log.Fatalln(err)
    }
}

Shape Assets

import "github.com/wenlng/go-captcha-assets/resources/shapes"

func Demo() {
    shapeMaps, err := shapes.GetShapes()
    if err != nil {
        log.Fatalln(err)
    }
}

Thumbnail Assets

import "github.com/wenlng/go-captcha-assets/resources/thumb"

func Demo() {
    imgs, err := thumb.GetImages()
    if err != nil {
        log.Fatalln(err)
    }
}

Tile Assets

import "github.com/wenlng/go-captcha-assets/resources/tiles"

func Demo() {
    graphs, err := tiles.GetTiles()
    if err != nil {
        log.Fatalln(err)
    }
    
    // slide
    var newGraphs = make([]*slide.GraphImage, 0, len(graphs))
    for i := 0; i < len(graphs); i++ {
        graph := graphs[i]
        newGraphs = append(newGraphs, &slide.GraphImage{
            OverlayImage: graph.OverlayImage,
            MaskImage:    graph.MaskImage,
            ShadowImage:  graph.ShadowImage,
        })
    }
}

Load Asset As Needed

// Example
import assets "github.com/wenlng/go-captcha-assets/bindata/images/image_v2_1"

func Demo() error {
    asset, err = assets.Asset("sourcedata/images/image-v2-1/image.jpg")
    if err != nil {
    return err
    }
    img, err = helper.DecodeByteToJpeg(asset)
    if err != nil {
    return err
    }
    fmt.Println(img)
}
Type Package Path Asset Path Image
Image bindata/images/image_v2_1 sourcedata/images/image-v2-1/image.jpg
Image bindata/images/image_v2_2 sourcedata/images/image-v2-2/image.jpg
Image bindata/images/image_v2_3 sourcedata/images/image-v2-3/image.jpg
Image bindata/images/image_v2_4 sourcedata/images/image-v2-4/image.jpg
Image bindata/images/image_v2_5 sourcedata/images/image-v2-5/image.jpg
Image bindata/images/image_v2_6 sourcedata/images/image-v2-6/image.jpg
Image bindata/images/image_v2_7 sourcedata/images/image-v2-7/image.jpg
Image bindata/images/image_v2_8 sourcedata/images/image-v2-8/image.jpg
Image bindata/images/image_v2_9 sourcedata/images/image-v2-9/image.jpg
Image bindata/images/image_v2_10 sourcedata/images/image-v2-10/image.jpg
Image bindata/images/image_v2_11 sourcedata/images/image-v2-11/image.jpg
Image bindata/images/image_v2_12 sourcedata/images/image-v2-12/image.jpg
Image bindata/images/image_v2_13 sourcedata/images/image-v2-13/image.jpg
Image bindata/images/image_v2_14 sourcedata/images/image-v2-14/image.jpg
Image bindata/images/image_v2_15 sourcedata/images/image-v2-15/image.jpg
Image bindata/images/image_v2_16 sourcedata/images/image-v2-16/image.jpg
-
Thumb bindata/thumbs/thumb_1 sourcedata/thumbs/thumb-1/thumb.jpg
Thumb bindata/thumbs/thumb_2 sourcedata/thumbs/thumb-2/thumb.jpg
Thumb bindata/thumbs/thumb_3 sourcedata/thumbs/thumb-3/thumb.jpg
Thumb bindata/thumbs/thumb_4 sourcedata/thumbs/thumb-4/thumb.jpg
Thumb bindata/thumbs/thumb_5 sourcedata/thumbs/thumb-5/thumb.jpg
-
Tile bindata/tiles/tile_1 sourcedata/tiles/tile-1/tile.png
Tile bindata/tiles/tile_1 sourcedata/tiles/tile-1/tile-shadow.png
Tile bindata/tiles/tile_1 sourcedata/tiles/tile-1/tile-mask.png
Tile bindata/tiles/tile_2 sourcedata/tiles/tile-2/tile.png
Tile bindata/tiles/tile_2 sourcedata/tiles/tile-2/tile-shadow.png
Tile bindata/tiles/tile_2 sourcedata/tiles/tile-2/tile-mask.png
Tile bindata/tiles/tile_3 sourcedata/tiles/tile-3/tile.png
Tile bindata/tiles/tile_3 sourcedata/tiles/tile-3/tile-shadow.png
Tile bindata/tiles/tile_3 sourcedata/tiles/tile-3/tile-mask.png
Tile bindata/tiles/tile_4 sourcedata/tiles/tile-4/tile.png
Tile bindata/tiles/tile_4 sourcedata/tiles/tile-4/tile-shadow.png
Tile bindata/tiles/tile_4 sourcedata/tiles/tile-4/tile-mask.png
-
Shape bindata/shapes/shape_1 sourcedata/shapes/shape-1/shape.png
Shape bindata/shapes/shape_2 sourcedata/shapes/shape-2/shape.png
Shape bindata/shapes/shape_3 sourcedata/shapes/shape-3/shape.png
Shape bindata/shapes/shape_4 sourcedata/shapes/shape-4/shape.png
Shape bindata/shapes/shape_5 sourcedata/shapes/shape-5/shape.png
Shape bindata/shapes/shape_6 sourcedata/shapes/shape-6/shape.png
Shape bindata/shapes/shape_7 sourcedata/shapes/shape-7/shape.png
Shape bindata/shapes/shape_8 sourcedata/shapes/shape-8/shape.png
Shape bindata/shapes/shape_9 sourcedata/shapes/shape-9/shape.png
Shape bindata/shapes/shape_10 sourcedata/shapes/shape-10/shape.png
Shape bindata/shapes/shape_11 sourcedata/shapes/shape-11/shape.png
Shape bindata/shapes/shape_12 sourcedata/shapes/shape-12/shape.png
Shape bindata/shapes/shape_13 sourcedata/shapes/shape-13/shape.png
-
Font bindata/fonts/fzshengsksjw_cu sourcedata/fonts/fzshengsksjw_cu/font.ttf

About

This is the assets of GoCaptcha

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages