mirror of
https://github.com/Belphemur/CBZOptimizer.git
synced 2025-10-13 20:18:52 +02:00
fix(webp): fix installing newer version of webp
This commit is contained in:
7
.vscode/launch.json
vendored
7
.vscode/launch.json
vendored
@@ -4,6 +4,13 @@
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Launch file",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "debug",
|
||||
"program": "${file}"
|
||||
},
|
||||
{
|
||||
"name": "Optimize Testdata",
|
||||
"type": "go",
|
||||
|
@@ -1,10 +1,13 @@
|
||||
package webp
|
||||
|
||||
import (
|
||||
"github.com/belphemur/go-webpbin/v2"
|
||||
"fmt"
|
||||
"image"
|
||||
"io"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/belphemur/go-webpbin/v2"
|
||||
)
|
||||
|
||||
const libwebpVersion = "1.6.0"
|
||||
@@ -15,8 +18,18 @@ func PrepareEncoder() error {
|
||||
prepareMutex.Lock()
|
||||
defer prepareMutex.Unlock()
|
||||
container := webpbin.NewCWebP(webpbin.SetLibVersion(libwebpVersion))
|
||||
return container.BinWrapper.Run()
|
||||
version, err := container.Version()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(version, libwebpVersion) {
|
||||
return fmt.Errorf("unexpected webp version: got %s, want %s", version, libwebpVersion)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Encode(w io.Writer, m image.Image, quality uint) error {
|
||||
return webpbin.NewCWebP(webpbin.SetLibVersion(libwebpVersion)).
|
||||
Quality(quality).
|
||||
|
Reference in New Issue
Block a user