Documentation
¶
Index ¶
- Variables
- func GenerateThumbnail(data []byte, maxSize int) ([]byte, error)
- func GetImageInfo(data []byte) (width, height int, format string, err error)
- type CompressStep
- type ExtractMetadataStep
- type FormatStep
- type GrayscaleStep
- type ImageConfig
- type ImageProcessor
- func (p *ImageProcessor) GetDimensions(reader io.Reader) (int, int, error)
- func (p *ImageProcessor) Process(ctx context.Context, input []byte) ([]byte, error)
- func (p *ImageProcessor) ProcessFromFile(ctx context.Context, filePath string) ([]byte, error)
- func (p *ImageProcessor) ProcessFromReader(ctx context.Context, reader io.Reader) ([]byte, error)
- func (p *ImageProcessor) Resize(reader io.Reader, width, height uint) (io.Reader, error)
- type NativeProcessor
- type PipelineImageProcessor
- type ProcessingPipeline
- type ProcessingStep
- type ResizeOptions
- type ResizeStep
- type Resizer
- type ValidateStep
- type WatermarkStep
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Thumbnail = ResizeOptions{Width: 245, Height: 156, Quality: 80} Small = ResizeOptions{Width: 500, Height: 500, Quality: 85} Medium = ResizeOptions{Width: 750, Height: 750, Quality: 85} Large = ResizeOptions{Width: 1000, Height: 1000, Quality: 90} )
Standard sizes
Functions ¶
func GenerateThumbnail ¶
GenerateThumbnail 生成缩略图
Types ¶
type CompressStep ¶
type CompressStep struct {
// contains filtered or unexported fields
}
CompressStep 压缩步骤
type FormatStep ¶
type FormatStep struct {
// contains filtered or unexported fields
}
FormatStep 格式转换步骤
type ImageConfig ¶
type ImageConfig struct {
MaxWidth int `json:"max_width"`
MaxHeight int `json:"max_height"`
Quality int `json:"quality"` // 1-100
Format string `json:"format"` // jpeg, png, webp
Watermark string `json:"watermark"` // 水印文字
Compress bool `json:"compress"` // 是否压缩
Grayscale bool `json:"grayscale"` // 是否灰度
}
ImageConfig 图片配置
type ImageProcessor ¶
type ImageProcessor struct {
// contains filtered or unexported fields
}
ImageProcessor 图片处理器
func NewImageProcessor ¶
func NewImageProcessor(config ImageConfig) *ImageProcessor
NewImageProcessor 创建图片处理器
func (*ImageProcessor) GetDimensions ¶
GetDimensions 获取图片尺寸(实现 Resizer 接口)
func (*ImageProcessor) ProcessFromFile ¶
ProcessFromFile 从文件处理
func (*ImageProcessor) ProcessFromReader ¶
ProcessFromReader 从 Reader 处理
type NativeProcessor ¶
type NativeProcessor struct{}
NativeProcessor implements Resizer using pure Go libraries This avoids CGO dependency (libvips) for easier deployment
func NewNativeProcessor ¶
func NewNativeProcessor() *NativeProcessor
func (*NativeProcessor) GetDimensions ¶
type PipelineImageProcessor ¶
type PipelineImageProcessor interface {
Process(ctx interface{}, input []byte) ([]byte, error)
ProcessFromFile(ctx interface{}, filePath string) ([]byte, error)
}
PipelineImageProcessor defines the interface for pipeline-based image processing
type ProcessingPipeline ¶
type ProcessingPipeline struct {
// contains filtered or unexported fields
}
ProcessingPipeline 处理管道
func NewProcessingPipeline ¶
func NewProcessingPipeline(config ImageConfig) *ProcessingPipeline
NewProcessingPipeline 创建处理管道
type ProcessingStep ¶
ProcessingStep 处理步骤接口
type ResizeOptions ¶
ResizeOptions defines options for image resizing
type ResizeStep ¶
type ResizeStep struct {
// contains filtered or unexported fields
}
ResizeStep 调整大小步骤
type Resizer ¶
type Resizer interface {
// Resize creates a thumbnail with specified dimensions
Resize(reader io.Reader, width, height uint) (io.Reader, error)
// GetDimensions returns image width and height
GetDimensions(reader io.Reader) (int, int, error)
}
Resizer defines interface for simple image resizing
type WatermarkStep ¶
type WatermarkStep struct {
// contains filtered or unexported fields
}
WatermarkStep 水印步骤
Click to show internal directories.
Click to hide internal directories.