Documentation
¶
Index ¶
- func BatchResize(ctx context.Context, req BatchResizeRequest, onProgress func(done, total int)) ([]string, error)
- func CancelJob(id string) bool
- func RegisterCancel(id string, cancel context.CancelFunc)
- func SetJob(id string, job *ResizerJob)
- func StartCleanup(ctx context.Context, ttl time.Duration)
- type BatchResizeRequest
- type ResizeTarget
- type ResizerJob
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BatchResize ¶
func BatchResize(ctx context.Context, req BatchResizeRequest, onProgress func(done, total int)) ([]string, error)
BatchResize processes images in SourceDir and exports resized variants to DestinationDir.
func RegisterCancel ¶
func RegisterCancel(id string, cancel context.CancelFunc)
RegisterCancel registers a cancel func.
Types ¶
type BatchResizeRequest ¶
type BatchResizeRequest struct {
SourceDir string `json:"source_dir"`
DestinationDir string `json:"destination_dir"`
Presets []string `json:"presets"` // "web-optimized", "social-media", "thumbnails"
CustomWidths []int `json:"custom_widths"` // e.g. [800, 1024]
Quality int `json:"quality"` // 1 - 100
}
BatchResizeRequest specifies source, destination, and selected presets.
type ResizeTarget ¶
type ResizeTarget struct {
Name string `json:"name"`
Width int `json:"width"`
Height int `json:"height"`
Fit bool `json:"fit"`
}
ResizeTarget defines dimensions and fitting mode for a resized variant.
func ResolveTargets ¶
func ResolveTargets(presets []string, customWidths []int) []ResizeTarget
ResolveTargets resolves list of ResizeTargets from presets and custom widths.
type ResizerJob ¶
type ResizerJob struct {
shared.Job
SourceDir string `json:"source_dir"`
DestinationDir string `json:"destination_dir"`
TotalImages int `json:"total_images"`
ProcessedCount int `json:"processed_count"`
GeneratedFiles []string `json:"generated_files"`
// contains filtered or unexported fields
}
ResizerJob tracks the background batch resizing job.
func (*ResizerJob) SetDone ¶
func (j *ResizerJob) SetDone(files []string)
SetDone marks the job as done and stores generated files.
func (*ResizerJob) SetFailed ¶
func (j *ResizerJob) SetFailed(errMsg string)
SetFailed marks the job as failed with an error message.
func (*ResizerJob) SetProgress ¶
func (j *ResizerJob) SetProgress(done, total int)
SetProgress updates the job's processed count, total, and progress percentage.
func (*ResizerJob) Snapshot ¶
func (j *ResizerJob) Snapshot() ResizerJob
Snapshot returns a thread-safe copy of the job's state.