1
0
mirror of https://github.com/coalaura/ffwebp.git synced 2025-09-09 06:19:55 +00:00
This commit is contained in:
2025-08-11 21:17:25 +02:00
parent 06bf222988
commit 738a9f42aa
19 changed files with 442 additions and 12 deletions

View File

@@ -0,0 +1,38 @@
package saturation
import (
"fmt"
"image"
"strconv"
"github.com/anthonynsimon/bild/adjust"
"github.com/coalaura/ffwebp/internal/effects"
"github.com/coalaura/ffwebp/internal/logx"
)
type impl struct{}
func init() {
effects.Register(impl{})
}
func (impl) String() string {
return "saturation"
}
func (impl) Apply(img image.Image, args string) (image.Image, error) {
var change float64 = 0.1
if args != "" {
f64, err := strconv.ParseFloat(args, 64)
if err != nil || f64 < -1 || f64 > 1 || f64 == 0 {
return nil, fmt.Errorf("invalid saturation change: %s", args)
}
change = f64
}
logx.Printf(" applying saturation (change=%.f)\n", change)
return adjust.Saturation(img, change), nil
}