feat: add dithering param and parallel frame rendering for GIF

- Add dithering bool param to GIFRequest (default true)
- Parallelize frame rendering with goroutines
- Conditional Floyd-Steinberg dithering for speed vs quality tradeoff
This commit is contained in:
devilreef 2026-01-23 00:51:38 +06:00
parent 0cbbe647f9
commit fb3c4a0107
4 changed files with 29 additions and 12 deletions

View file

@ -19,6 +19,7 @@ type GIFRequest struct {
Width int `json:"width"` // default 512
Height int `json:"height"` // default 512
Delay int `json:"delay"` // centiseconds between frames, default 5
Dithering *bool `json:"dithering"` // Floyd-Steinberg dithering, default true
}
// ErrorResponse represents an error returned by the API
@ -56,4 +57,8 @@ func (r *GIFRequest) ApplyDefaults() {
if r.Background == "" {
r.Background = "#FFFFFF"
}
if r.Dithering == nil {
defaultDithering := true
r.Dithering = &defaultDithering
}
}