factory

package
v1.1.4-0...-af12951 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 15 Imported by: 0

README

factory

Originally from FloatTech/imgfactory, operating raw image.NRGBA object.

Documentation

Overview

Package factory provides image manipulation utilities built on top of gg.

factory 包提供基于 gg 的图像操作工具库。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GIF2Base64

func GIF2Base64(gifImage *gif.GIF) (string, error)

GIF2Base64 gif 内容转为 base64

func GetPaletted

func GetPaletted(im image.Image) *image.Paletted

GetPaletted 将image.Image转换为 *Paletted。最多256色

func Limit

func Limit(img image.Image, xmax, ymax int) image.Image

Limit 限制图片在 xmax*ymax 之内

func Load

func Load(path string) (img image.Image, err error)

Load 加载图片

func MergeGif

func MergeGif(delay int, im []*image.NRGBA) *gif.GIF

MergeGif 合并成gif,1 dealy 10毫秒

func Parse

func Parse(r io.Reader) (img image.Image, err error)

Parse 解析图片数据流

func RenderText

func RenderText(text, font string, width, fontSize int) (txtPic image.Image, err error)

RenderText 文字转图片 width 是图片宽度

func RenderTextWith

func RenderTextWith(text string, font []byte, width, fontSize int) (txtPic image.Image, err error)

RenderTextWith 文字转图片 width 是图片宽度

func ToBase64

func ToBase64(img image.Image) (base64Bytes []byte, err error)

ToBase64 img 内容转为base64

func ToBytes

func ToBytes(img image.Image) (data []byte, err error)

ToBytes img 内容转为 []byte

func WriteTo

func WriteTo(img image.Image, f io.Writer) (n int64, err error)

WriteTo img 内容写入 Writer

Types

type Factory

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

Factory 处理中图像

func LoadAllFrames

func LoadAllFrames(path string, w, h int) ([]*Factory, error)

LoadAllFrames 加载每一帧图片

func LoadAllTrueFrames

func LoadAllTrueFrames(path string, w, h int) ([]*Factory, error)

LoadAllTrueFrames 加载每一帧显示出的图片

func LoadFirstFrame

func LoadFirstFrame(path string, w, h int) (*Factory, error)

LoadFirstFrame 载入图片第一帧作底图

func MergeH

func MergeH(im []*image.NRGBA) *Factory

MergeH 纵向合并图片

func MergeW

func MergeW(im []*image.NRGBA) *Factory

MergeW 横向合并图片

func NewFactory

func NewFactory(im *image.NRGBA) *Factory

NewFactory creates a Factory from an existing *image.NRGBA.

NewFactory 从已有的 *image.NRGBA 创建 Factory。

func NewFactoryBG

func NewFactoryBG(w, h int, fillColor color.Color) *Factory

NewFactoryBG creates a new Factory with a solid background color.

NewFactoryBG 创建一个具有纯色背景的新 Factory。

func ParseFirstFrame

func ParseFirstFrame(r io.Reader, w, h int) (*Factory, error)

ParseFirstFrame 解析图片第一帧作底图

func Rotate

func Rotate(img image.Image, angle float64, w, h int) *Factory

Rotate 旋转

func Size

func Size(im image.Image, w, h int) *Factory

Size 变形

func Text

func Text(font string, size float64, col []int, col1 []int, txt string) *Factory

Text 文本框 字体, 大小, 颜色 , 背景色, 文本

func (*Factory) AdjustBrightness

func (dst *Factory) AdjustBrightness(s float64) *Factory

AdjustBrightness 亮度(-100, 100)

func (*Factory) AdjustContrast

func (dst *Factory) AdjustContrast(a float64) *Factory

AdjustContrast 对比度(-100, 100)

func (*Factory) AdjustSaturation

func (dst *Factory) AdjustSaturation(a float64) *Factory

AdjustSaturation 饱和度(-100, 100)

func (*Factory) Blur

func (dst *Factory) Blur(a float64) *Factory

Blur 模糊图像 正数

func (*Factory) Circle

func (dst *Factory) Circle(r int) *Factory

Circle 获取圆图

func (*Factory) Clip

func (dst *Factory) Clip(w, h, x, y int) *Factory

Clip 剪取方图

func (*Factory) ClipCircle

func (dst *Factory) ClipCircle(x, y, r int) *Factory

ClipCircle 扣取圆

func (*Factory) ClipCircleFix

func (dst *Factory) ClipCircleFix(x, y, r int) *Factory

ClipCircleFix 裁取圆图

func (*Factory) Clone

func (dst *Factory) Clone() *Factory

Clone 克隆

func (*Factory) FlipH

func (dst *Factory) FlipH() *Factory

FlipH 水平翻转

func (*Factory) FlipV

func (dst *Factory) FlipV() *Factory

FlipV 垂直翻转

func (*Factory) Grayscale

func (dst *Factory) Grayscale() *Factory

Grayscale 灰度

func (*Factory) H

func (dst *Factory) H() int

H returns the height of the image in pixels.

H 返回图像的高度(像素)。

func (*Factory) Image

func (dst *Factory) Image() *image.NRGBA

Image returns the underlying *image.NRGBA.

Image 返回底层的 *image.NRGBA。

func (*Factory) InsertBottom

func (dst *Factory) InsertBottom(im image.Image, w, h, x, y int) *Factory

InsertBottom 底部插入图片

func (*Factory) InsertBottomC

func (dst *Factory) InsertBottomC(im image.Image, w, h, x, y int) *Factory

InsertBottomC 底部插入图片 x,y是中心点

func (*Factory) InsertText

func (dst *Factory) InsertText(font string, size float64, col []int, x, y float64, txt string) *Factory

InsertText 插入文本

func (*Factory) InsertUp

func (dst *Factory) InsertUp(im image.Image, w, h, x, y int) *Factory

InsertUp 上部插入图片

func (*Factory) InsertUpC

func (dst *Factory) InsertUpC(im image.Image, w, h, x, y int) *Factory

InsertUpC 上部插入图片 x,y是中心点

func (*Factory) InsertUpG

func (dst *Factory) InsertUpG(im []*image.NRGBA, w, h, x, y int) []*image.NRGBA

InsertUpG gif 上部插入图片

func (*Factory) Invert

func (dst *Factory) Invert() *Factory

Invert 反色

func (*Factory) Relief

func (dst *Factory) Relief() *Factory

Relief 浮雕

func (*Factory) Reshape

func (dst *Factory) Reshape(w, h int) *Factory

Reshape 变形

func (*Factory) Sharpen

func (dst *Factory) Sharpen(a float64) *Factory

Sharpen 锐化

func (*Factory) W

func (dst *Factory) W() int

W returns the width of the image in pixels.

W 返回图像的宽度(像素)。

Jump to

Keyboard shortcuts

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