ximage

package
v0.0.0-...-b147793 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: BSD-3-Clause Imports: 14 Imported by: 1

Documentation

Overview

Package ximage 图片处理、图像字体、验证码

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanvasScale

func CanvasScale(width int, height int, scale float64) (int, int)

CanvasScale 将宽高调整为指定的比例,在调整时,会保持其中一条边的值不变,让另一条表按照比例放大

func DrawLine

func DrawLine(img SetAble, start image.Point, end image.Point, c color.Color)

func DrawRandomLine

func DrawRandomLine(img *image.RGBA)

func EncodeEmbed

func EncodeEmbed(img image.Image) (string, error)

func Load

func Load(fp string) (image.Image, error)

Load 加载图片文件,并依据文件后缀自动选用合适的解析器解析图片

默认支持:.png、.jpeg、.jpg、.gif 其他后缀可以通过 RegisterDecoder 方法注册实现支持

func RandomColor

func RandomColor() color.RGBA

func RandomPoint

func RandomPoint(size image.Point) image.Point

func RegisterDecoder

func RegisterDecoder(ext string, fn DecoderFunc)

RegisterDecoder 注册新的解析解析方法 ext: 文件后缀,如 .bmp

func Resize

func Resize(src *image.RGBA, width, height int) *image.RGBA

func ToGrayColor

func ToGrayColor(c color.Color) color.Gray

func ToGrayImage

func ToGrayImage(img image.Image) *image.Gray

ToGrayImage 将彩色图片转换为黑白图片

Types

type DecoderFunc

type DecoderFunc func(io.Reader) (image.Image, error)

func GetDecoderFuncByExt

func GetDecoderFuncByExt(ext string) (DecoderFunc, error)

GetDecoderFuncByExt 获取已注册的好默认内置支持的 DecoderFunc

type SetAble

type SetAble interface {
	Set(x, y int, c color.Color)
}

Directories

Path Synopsis
Package caption 图像验证码,目前已内置:
Package caption 图像验证码,目前已内置:
Package pixelfont
Package pixelfont

Jump to

Keyboard shortcuts

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