watermark

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

README

Go内嵌静态资源go-bindata的安装及使用

go get -u github.com/jteeuwen/go-bindata/...
  • 命令
go-bindata -pkg textwatermark -o font.go Songti.ttc

Documentation

Overview

Package watermark

@author: xwc1125

Package watermark

@author: xwc1125 @date: 2021/3/15

Index

Constants

View Source
const (
	TopLeft int = iota
	TopRight
	BottomLeft
	BottomRight
	Center
)

水印的位置

Variables

View Source
var MaxTextLen = 80

MaxTextLen 进行切割时的最大文字长度

Functions

func DecodeGif

func DecodeGif(imgFile *os.File) (*gif.GIF, error)

DecodeImg 解析gif

func DecodeImg

func DecodeImg(imgFile *os.File) (image.Image, error)

DecodeImg 解析Image(png,jpeg)

func ImageNRGBAToBytes

func ImageNRGBAToBytes(imgType string, img *image.NRGBA) ([]byte, error)

ImageToBytes 将image.NRGBA转换为[]bytes

func ImageToBytes

func ImageToBytes(imgType string, img image.Image) ([]byte, error)

ImageToBytes 将image.Image转换为[]bytes

func ImageToRgba

func ImageToRgba(img image.Image) *image.NRGBA

ImageToRgba 将image.Image转换为*image.NRGBA

func New

func New(pattern string) (*water, error)

New ...

func WriterGifImage

func WriterGifImage(gifImg2 *gif.GIF, waterImage image.Image, position *Position) (*gif.GIF, error)

WriterGifImage 添加图片水印函数

func WriterGifText

func WriterGifText(gifImg2 *gif.GIF, typeface []FontInfo) (*gif.GIF, error)

WriterGifText 添加文字水印函数

func WriterGifToFile

func WriterGifToFile(img *gif.GIF, desFileName string) error

WriterGifToFile 保存gif到新文件中

func WriterImage

func WriterImage(img *image.NRGBA, watermark image.Image, position *Position) *image.NRGBA

WriterImage 往图片上加上图片水印

func WriterText

func WriterText(img *image.NRGBA, typeface []FontInfo) (*image.NRGBA, error)

WriterText 添加文字水印函数

func WriterTexts

func WriterTexts(img *image.NRGBA, fInfo FontInfo, texts []string) (*image.NRGBA, error)

func WriterToFile

func WriterToFile(imgType string, img *image.NRGBA, desFileName string) error

WriterToFile 保存到新文件中

Types

type Dxy

type Dxy struct {
	// contains filtered or unexported fields
}

Dxy ...

type FontInfo

type FontInfo struct {
	Ttf      string         `json:"ttf" mapstructure:"ttf"`           // 文字字体
	Font     *truetype.Font `json:"font" mapstructure:"font"`         // 文字字体
	Size     float64        `json:"size" mapstructure:"size"`         // 文字大小
	Message  string         `json:"message" mapstructure:"message"`   // 文字内容
	Position Position       `json:"position" mapstructure:"position"` // 文字存放位置
}

FontInfo 定义添加的文字信息

type Position

type Position struct {
	Position int   `json:"position" mapstructure:"position"` // 文字存放位置
	Dx       int   `json:"dx" mapstructure:"dx"`             // 文字x轴留白距离
	Dy       int   `json:"dy" mapstructure:"dy"`             // 文字y轴留白距离
	R        uint8 `json:"r" mapstructure:"r"`               // 文字颜色值RGBA中的R值
	G        uint8 `json:"g" mapstructure:"g"`               // 文字颜色值RGBA中的G值
	B        uint8 `json:"b" mapstructure:"b"`               // 文字颜色值RGBA中的B值
	A        uint8 `json:"a" mapstructure:"a"`               // 文字颜色值RGBA中的A值
}

Position ...

Jump to

Keyboard shortcuts

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