commit 40afa63773a71fe1e7f88fd6e0676ac4ce26324b
parent 41dac6f1dc7e1dd9044068167f7f0bedb9dc5d5a
Author: Jack Mordaunt <jackmordaunt.dev@gmail.com>
Date: Wed, 3 Jan 2024 16:26:17 +0800
cmd: handle flags properly
Set the lossless and quality options.
Signed-off-by: Jack Mordaunt <jackmordaunt.dev@gmail.com>
Diffstat:
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/cmd/main.go b/cmd/main.go
@@ -75,7 +75,12 @@ func encodeWebp(args []string) error {
if err != nil {
return fmt.Errorf("decoding src image: %w", err)
}
- if err := webp.Encode(dstf, img); err != nil {
+ opts := []webp.EncodeOption{}
+ opts = append(opts, webp.Quality(float32(quality)))
+ if lossless {
+ opts = append(opts, webp.Lossless())
+ }
+ if err := webp.Encode(dstf, img, opts...); err != nil {
return fmt.Errorf("encoding webp: %w", err)
}
return nil