Documentation
¶
Index ¶
- func CreateImage(path string, img image.Image) error
- func GenerateOutputPath(src, dst string, op string, params map[string]string) string
- func ProcessBatch(ctx context.Context, patterns []string, opts *BatchOptions, ...) error
- func ProcessVerify(ctx context.Context, patterns []string, opts *BatchOptions) error
- func SaveResults(path string, results ...*BatchResult) error
- type BatchOptions
- type BatchProcessor
- type BatchProgress
- type BatchResult
- type ImageHandler
- func (h *ImageHandler) Adjust(brightness, contrast float64) error
- func (h *ImageHandler) Blur(sigma float64) error
- func (h *ImageHandler) ConvertFormat(format string) error
- func (h *ImageHandler) Crop(x, y, width, height int) error
- func (h *ImageHandler) Flip() error
- func (h *ImageHandler) Flop() error
- func (h *ImageHandler) GetInfo() *ImageInfo
- func (h *ImageHandler) Resize(width, height int) error
- func (h *ImageHandler) Rotate(angle float64) error
- func (h *ImageHandler) Save(dstPath string) error
- func (h *ImageHandler) Sharpen(sigma float64) error
- func (h *ImageHandler) Verify() error
- type ImageInfo
- type ImageProcessor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateOutputPath ¶
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 处理验证结果
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) GetProgress ¶
func (b *BatchProcessor) GetProgress() *BatchProgress
GetProgress 获取处理进度
func (*BatchProcessor) Process ¶
func (b *BatchProcessor) Process(processor func(*ImageHandler) error) error
Process 执行批量处理
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 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) ConvertFormat ¶
func (h *ImageHandler) ConvertFormat(format string) error
ConvertFormat 转换图片格式
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 ¶
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 处理图片的接口
Click to show internal directories.
Click to hide internal directories.