imaging

package
v0.0.57 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateImage

func CreateImage(path string, img image.Image) error

func GenerateOutputPath

func GenerateOutputPath(src, dst string, op string, params map[string]string) string

GenerateOutputPath 生成输出文件路径

func ProcessBatch

func ProcessBatch(ctx context.Context, patterns []string, opts *BatchOptions, processor func(*ImageHandler) error) error

ProcessBatch 通用批处理函数

func ProcessVerify

func ProcessVerify(ctx context.Context, patterns []string, opts *BatchOptions) error

ProcessVerify 处理验证结果

func SaveResults

func SaveResults(path string, results ...*BatchResult) error

SaveResults 保存结果到文件

Types

type BatchOptions

type BatchOptions struct {
	DstDir     string            // 输出目录
	Workers    int               // 并发数
	Params     map[string]string // 处理参数
	Op         string            // 操作类型
	ResultFile string            // 结果输出文件路径
}

BatchOptions 批处理选项

type BatchProcessor

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

BatchProcessor 批量处理器

func NewBatchProcessor

func NewBatchProcessor(ctx context.Context, opts *BatchOptions) *BatchProcessor

NewBatchProcessor 创建批量处理器

func (*BatchProcessor) AddFiles

func (b *BatchProcessor) AddFiles(patterns ...string) error

AddFiles 添加待处理文件

func (*BatchProcessor) Errors

func (b *BatchProcessor) Errors() []string

Errors 获取错误信息

func (*BatchProcessor) GetProgress

func (b *BatchProcessor) GetProgress() *BatchProgress

GetProgress 获取处理进度

func (*BatchProcessor) Process

func (b *BatchProcessor) Process(processor func(*ImageHandler) error) error

Process 执行批量处理

func (*BatchProcessor) Results

func (b *BatchProcessor) Results() []*BatchResult

Results 获取处理结果

type BatchProgress

type BatchProgress struct {
	Total     int     `json:"total"`
	Completed int     `json:"completed"`
	Failed    int     `json:"failed"`
	Progress  float64 `json:"progress"`
}

BatchProgress 批处理进度

type BatchResult

type BatchResult struct {
	Path      string     `json:"path"`
	Error     string     `json:"error,omitempty"`
	Image     *ImageInfo `json:"image"`
	Timestamp time.Time  `json:"timestamp"`
}

type ImageHandler

type ImageHandler struct {
	SrcPath string
	DstPath string
	// contains filtered or unexported fields
}

ImageHandler 图片处理器

func NewImageHandler

func NewImageHandler(ctx context.Context, srcPath, dstPath string) (*ImageHandler, error)

NewImageHandler 创建新的图片处理器

func NewImageHandlerV1

func NewImageHandlerV1(ctx context.Context, srcPath, dstPath string) (*ImageHandler, error)

func NewImageHandlerV2

func NewImageHandlerV2(ctx context.Context, srcPath, dstPath string) (*ImageHandler, error)

func (*ImageHandler) Adjust

func (h *ImageHandler) Adjust(brightness, contrast float64) error

Adjust 调整亮度和对比度

func (*ImageHandler) Blur

func (h *ImageHandler) Blur(sigma float64) error

Blur 模糊处理

func (*ImageHandler) ConvertFormat

func (h *ImageHandler) ConvertFormat(format string) error

ConvertFormat 转换图片格式

func (*ImageHandler) Crop

func (h *ImageHandler) Crop(x, y, width, height int) error

Crop 裁剪图片

func (*ImageHandler) Flip

func (h *ImageHandler) Flip() error

Flip 垂直翻转

func (*ImageHandler) Flop

func (h *ImageHandler) Flop() error

Flop 水平翻转

func (*ImageHandler) GetInfo

func (h *ImageHandler) GetInfo() *ImageInfo

GetInfo 获取图片信息

func (*ImageHandler) Resize

func (h *ImageHandler) Resize(width, height int) error

Resize 调整图片大小

func (*ImageHandler) Rotate

func (h *ImageHandler) Rotate(angle float64) error

Rotate 旋转图片

func (*ImageHandler) Save

func (h *ImageHandler) Save(dstPath string) error

Save 保存图片到指定路径

func (*ImageHandler) Sharpen

func (h *ImageHandler) Sharpen(sigma float64) error

Sharpen 锐化处理

func (*ImageHandler) Verify

func (h *ImageHandler) Verify() error

Verify 验证图片完整性

type ImageInfo

type ImageInfo struct {
	Path    string `json:"path"`
	Format  string `json:"format"`
	Width   int    `json:"width"`
	Height  int    `json:"height"`
	Size    int64  `json:"size"`
	Invalid bool   `json:"invalid"`
}

ImageInfo 图片信息

func ProcessImage

func ProcessImage(ctx context.Context, src string, dst string, op string, params map[string]string, processor func(*ImageHandler) error) (*ImageInfo, error)

func VerifyImage

func VerifyImage(ctx context.Context, path string) (*ImageInfo, error)

VerifyImage 验证图片完整性

type ImageProcessor

type ImageProcessor interface {
	Adjust(brightness float64, contrast float64) error
	Blur(sigma float64) error
	ConvertFormat(format string) error
	Crop(x int, y int, width int, height int) error
	Flip() error
	Flop() error
	GetInfo() *ImageInfo
	Resize(width int, height int) error
	Rotate(angle float64) error
	Save(dstPath string) error
	Sharpen(sigma float64) error
	Verify() error
}

ImageProcessor 处理图片的接口

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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